/**
 * Emerald Theme - Main Entry Point
 *
 * Import this file to get all theme styles.
 * The layer order is established in theme.css.
 *
 * Layer order (lowest to highest precedence):
 * 1. theme      - CSS custom properties
 * 2. base       - Element styles (body, headings, links)
 * 3. components - Component styles, buttons, utilities
 */

/**
 * Emerald Theme - CSS Custom Properties and Layer Order
 *
 * This file defines:
 * 1. The cascade layer order for the entire theme
 * 2. CSS custom properties (variables) for colors, typography, and spacing
 *
 * Import this file first in your application to establish layer precedence.
 */

/* Establish layer order - layers listed first have lowest precedence */

@layer theme, base, components;

/* Theme layer: CSS Custom Properties */

@layer theme {
  :root {
    /* Colors - Primary */
    --color-white: #ffffff;
    --color-black: #1d1d1e;
    --color-green: #32d486;
    --color-green-light: color-mix(in srgb, var(--color-green) 80%, white 20%);
    --color-green-dark: color-mix(in srgb, var(--color-green) 80%, black 20%);
    --color-red: #fb285a;
    --color-red-light: color-mix(in srgb, var(--color-red) 80%, white 20%);
    --color-red-dark: color-mix(in srgb, var(--color-red) 80%, black 20%);

    /* Colors - Gray Scale */
    --color-gray-50: #f4f4f4;
    --color-gray-100: #e5e5e7;
    --color-gray-200: #d2d2d2;
    --color-gray-500: #8e8e8e;
    --color-gray-700: #616162;
    --color-gray-800: #4a4a4b;
    --color-gray-900: #343435;

    /* Typography */
    --font-family-sans: Inter, sans-serif;
    --font-family-mono: "IBM Plex Mono", monospace;
    --line-height-ratio: 1.6;

    /* Font Sizes - Pre-calculated with line heights */
    --font-size-xs: 12px;
    --line-height-xs: calc(12px * var(--line-height-ratio));
    --font-size-sm: 16px;
    --line-height-sm: calc(16px * var(--line-height-ratio));
    --font-size-md: 20px;
    --line-height-md: calc(20px * var(--line-height-ratio));
    --font-size-lg: 32px;
    --line-height-lg: calc(32px * var(--line-height-ratio));
    --font-size-xl: 40px;
    --line-height-xl: calc(40px * var(--line-height-ratio));

    /* Font Weights */
    --font-weight-light: 100;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;

    /* Spacing */
    --spacing-xs: 5px;
    --spacing-sm: 10px;
    --spacing-md: 20px;
    --spacing-lg: 40px;
    --spacing-xl: 50px;
    --spacing-2xl: 100px;

    /* Content padding by breakpoint (use with media queries) */
    --content-padding-mobile: 40px;
    --content-padding-tablet: 50px;
    --content-padding-mini: 90px;
    --content-padding-desktop: 200px;

    /* Transitions */
    --transition-fast: 0.3s;

    /* Borders */
    --border-color: var(--color-gray-200);
    --border-width: 1px;

    /* Max widths */
    --content-max-width: 1200px;
  }
}

/**
 * Media Query Breakpoints Reference
 * ----------------------------------
 * These breakpoints cannot be defined as CSS variables for use in @media queries.
 * Use these values directly in your media queries:
 *
 * Mobile (portrait):
 *   @media screen and (max-width: 667px) { ... }
 *
 * Tablet (landscape phones, portrait tablets):
 *   @media screen and (min-width: 668px) and (max-width: 1024px) { ... }
 *
 * Mini (small desktops, landscape tablets):
 *   @media screen and (min-width: 1025px) and (max-width: 1200px) { ... }
 *
 * Desktop (default, no media query needed):
 *   min-width: 1201px
 *
 * Shorthand for "not desktop" (mobile + tablet + mini):
 *   @media screen and (max-width: 1200px) { ... }
 *
 * Shorthand for "mobile or tablet":
 *   @media screen and (max-width: 1024px) { ... }
 */

/**
 * Emerald Theme - Base Element Styles
 *
 * Styles for standard HTML elements.
 * Requires theme.css to be imported first for CSS custom properties.
 */

@layer base {
  body {
    font-family: var(--font-family-sans);
    background-color: var(--color-gray-50);
    color: var(--color-black);
    margin: 0;
  }

  a {
    color: var(--color-black);
    text-decoration: none;
  }

  p {
    font-size: 20px;
    line-height: 32px;
    color: var(--color-gray-900);

    &.short {
      max-width: 770px;
    }
  }

  small {
    font-size: 12px;
    line-height: calc(12px * var(--line-height-ratio));
    font-weight: var(--font-weight-normal);

    &.label {
      margin-right: var(--spacing-sm);
    }
  }

  h1 {
    font-size: 40px;
    line-height: calc(40px * var(--line-height-ratio));
    font-weight: var(--font-weight-medium);
    margin: var(--spacing-md) 0;

    &.lead {
      margin-top: var(--spacing-2xl);
    }

    @media screen and (max-width: 667px) {
      font-size: 32px;
      line-height: calc(32px * var(--line-height-ratio));
    }
  }

  h2 {
    font-size: 32px;
    line-height: calc(32px * var(--line-height-ratio));
    font-weight: var(--font-weight-medium);

    @media screen and (max-width: 667px) {
      font-size: 20px;
      line-height: calc(20px * var(--line-height-ratio));
    }
  }

  h3 {
    font-size: 20px;
    line-height: calc(20px * var(--line-height-ratio));
    font-weight: var(--font-weight-medium);

    @media screen and (max-width: 667px) {
      font-size: 16px;
      line-height: calc(16px * var(--line-height-ratio));
    }
  }

  code,
  code pre {
    font-family: var(--font-family-mono);
    font-weight: var(--font-weight-light);
  }
}

/**
 * Emerald Theme - Header Component Styles
 */

@layer components {
  #header {
    display: grid;
    grid-template-columns: 32px minmax(auto, 150px) minmax(20px, 100%) auto;
    margin: 36px 0;
    padding: 0 var(--content-padding-desktop);
    max-width: var(--content-max-width);

    .burger {
      display: none;
    }

    .logo {
      grid-column: 1;
    }

    .brand {
      grid-column: 2;
      font-weight: var(--font-weight-semibold);
      font-size: 25px;
      line-height: 40px;
      padding-left: var(--spacing-sm);
      margin-top: var(--spacing-xs);

      a {
        text-decoration: none;
        color: var(--color-gray-900);
      }

      .brand-sub {
        font-weight: 200;
        color: var(--color-gray-900);
        padding-left: var(--spacing-sm);
      }
    }

    .nav {
      grid-column: 4;
      margin-top: 13px;
      display: flex;
      gap: var(--spacing-lg);

      a {
        text-decoration: none;
        transition: color var(--transition-fast);
        color: var(--color-gray-900);
        font-size: 16px;
        line-height: calc(16px * var(--line-height-ratio));
        font-weight: var(--font-weight-medium);

        &:hover {
          color: var(--color-gray-200);
        }
      }
    }

    .actions {
      display: flex;
      gap: var(--spacing-sm);

      .btn {
        background-color: black;
        color: var(--color-green);
        padding: var(--spacing-sm) 15px;
        cursor: pointer;
        transition: background var(--transition-fast), color var(--transition-fast);

        &.login {
          background: transparent;
          color: var(--color-white);
          border: var(--border-width) solid var(--color-white);

          &:hover {
            background: var(--color-white);
            color: var(--color-green);
          }
        }

        &.signup:hover {
          background: var(--color-gray-200);
        }
      }
    }

    /* Mini desktop (1025px - 1200px) */
    @media screen and (min-width: 1025px) and (max-width: 1200px) {
      padding: 0 var(--content-padding-mini);
    }

    /* Tablet (668px - 1024px) */
    @media screen and (min-width: 668px) and (max-width: 1024px) {
      padding: var(--spacing-md) 0 0 var(--content-padding-tablet);
      grid-template-columns: 64px minmax(auto, 150px) auto;
    }

    /* Mobile (up to 667px) */
    @media screen and (max-width: 667px) {
      grid-template-columns: 64px 80px auto;
      margin: 0;
      padding: var(--spacing-md) 0 0 30px;

      &.open {
        background-color: var(--color-white);
      }

      .burger {
        grid-column: 1;
        cursor: pointer;
        display: block;
      }

      .logo {
        grid-column: 2;
        margin-top: 8px;
        text-align: right;

        svg {
          width: 24px;
          height: 32px;
        }
      }

      .brand {
        grid-column: 3;
        margin-top: 6px;
        font-size: 20px;
        line-height: 32px;
      }

      .nav {
        display: none;
        position: absolute;
        top: 55px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: var(--color-gray-50);
        flex-direction: column;
        padding: var(--spacing-md) 0 0 30px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

        &.open {
          display: flex;
        }
      }
    }
  }
}

/**
 * Emerald Theme - Footer Component Styles
 */

@layer components {
  #footer {
    padding: var(--spacing-xl) var(--content-padding-desktop);
    margin-top: var(--spacing-xl);
    border-top: var(--border-width) solid var(--border-color);

    .links {
      display: grid;
      grid-template-columns: repeat(6, 100px);
      grid-column-gap: var(--spacing-2xl);
      padding-bottom: var(--spacing-xl);
      border-bottom: var(--border-width) solid var(--border-color);
      margin-bottom: var(--spacing-xl);

      h4 {
        font-size: 12px;
        line-height: calc(12px * var(--line-height-ratio));
        font-weight: var(--font-weight-medium);
      }

      ul {
        list-style: none;
        padding: 0;
        margin: 0;

        li {
          font-size: 12px;
          line-height: calc(12px * var(--line-height-ratio));
          font-weight: var(--font-weight-medium);
          margin-top: 6px;

          a {
            color: var(--color-gray-900);
            text-decoration: none;
          }
        }
      }
    }

    .sign p {
      font-size: 12px;
      line-height: calc(12px * var(--line-height-ratio));
      font-weight: var(--font-weight-normal);
    }

    /* Mini desktop (1025px - 1200px) */
    @media screen and (min-width: 1025px) and (max-width: 1200px) {
      padding: var(--content-padding-mini);

      .links {
        grid-template-columns: repeat(6, minmax(150px, auto));
        grid-column-gap: var(--spacing-md);
      }
    }

    /* Tablet (668px - 1024px) */
    @media screen and (min-width: 668px) and (max-width: 1024px) {
      padding: var(--spacing-xl);

      .links {
        grid-template-columns: repeat(3, minmax(150px, auto));
        grid-column-gap: var(--spacing-xl);
      }
    }

    /* Mobile (up to 667px) */
    @media screen and (max-width: 667px) {
      padding: var(--spacing-xl) var(--content-padding-mobile);

      .links {
        grid-template-columns: 100%;
        grid-column-gap: 0;

        .column {
          padding-bottom: var(--spacing-md);
          border-bottom: var(--border-width) solid var(--border-color);
        }

        ul li {
          font-weight: var(--font-weight-normal);
        }
      }
    }
  }
}

/**
 * Emerald Theme - Cookie Consent Component Styles
 */

@layer components {
  .cookie-consent {
    display: grid;
    grid-template-columns: minmax(auto, 80%) minmax(auto, 250px);
    background-color: var(--color-green);
    color: var(--color-white);
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    /* Show at the bottom - must also be at the bottom of the HTML */
    position: sticky;
    bottom: 0;

    .message {
      grid-column: 1;
      margin-left: var(--spacing-lg);

      p {
        color: var(--color-gray-900);
        margin: 0;
        padding-top: 7px;
      }
    }

    .actions {
      grid-column: 2;
      text-align: right;

      .btn {
        background-color: var(--color-gray-900);
        color: var(--color-gray-50);
      }
    }
  }
}

/**
 * Emerald Theme - Error Page Component Styles
 */

@layer components {
  .error {
    display: grid;
    grid-template-columns: 20% 70%;
    grid-column-gap: var(--spacing-lg);
    padding-top: var(--spacing-2xl);

    h1 {
      grid-column: 1;
      font-size: 96px;
      line-height: calc(96px * var(--line-height-ratio));
      font-weight: var(--font-weight-medium);
      text-align: right;
      color: var(--color-red);
    }

    p {
      grid-column: 2;
      text-align: left;
      margin-top: 42px;
      font-size: 64px;
      line-height: calc(64px * var(--line-height-ratio));
      font-weight: var(--font-weight-medium);
    }
  }
}

/**
 * Emerald Theme - Article/HTML Body Content Styles
 */

@layer components {
  .html-body {
    a {
      text-decoration: underline;
      color: var(--color-gray-700);
    }

    img {
      max-width: 80%;
      margin-left: 10%;
      height: auto;
    }

    hr {
      display: none;
    }

    h1, h2, h3, h4, h5, h6 {
      margin-top: 60px;
      margin-bottom: var(--spacing-lg);
    }

    @media screen and (max-width: 667px) {
      img {
        max-width: 90%;
        margin-left: 5%;
      }
    }
  }
}

/**
 * Emerald Theme - Components
 *
 * Buttons, grid layouts, alerts, and content container.
 */

@layer components {
  /* Content Container */
  #content {
    padding: 0 var(--content-padding-desktop);
    max-width: var(--content-max-width);

    @media screen and (min-width: 1025px) and (max-width: 1200px) {
      padding: 0 var(--content-padding-mini);
    }

    @media screen and (min-width: 668px) and (max-width: 1024px) {
      padding: 0 var(--content-padding-tablet);
    }

    @media screen and (max-width: 667px) {
      padding: 0 var(--content-padding-mobile);
    }
  }

  /* Button Base Styles */
  .btn {
    border: none;
    display: inline-block;
    padding: 15px 30px;
    margin: 0 var(--spacing-xs);
    font-size: 16px;
    font-weight: var(--font-weight-medium);
    line-height: 26px;
    text-align: center;
    text-decoration: none;
    border-radius: 0;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border var(--transition-fast);

    &.small {
      padding: 7px 15px;
    }

    &.primary {
      background: var(--color-green);
      color: var(--color-gray-900);

      &:hover {
        background: var(--color-white);
        color: var(--color-green);
      }
    }

    &.secondary {
      background: var(--color-gray-200);
      color: var(--color-gray-900);

      &:hover {
        background: var(--color-gray-100);
      }
    }

    &.danger {
      background: var(--color-red);
      color: var(--color-white);

      &:hover {
        background: var(--color-white);
        color: var(--color-red);
      }
    }
  }

  /* Grid Layouts */
  .columns-two {
    display: grid;
    grid-template-columns: 48% 48%;
    grid-column-gap: 4%;
  }

  .columns-three {
    display: grid;
    grid-template-columns: 32% 32% 32%;
    grid-column-gap: 2%;
  }

  .columns-four {
    display: grid;
    grid-template-columns: 24% 23% 23% 24%;
    grid-column-gap: 2%;
  }

  /* Alerts */
  .alert {
    padding: 30px var(--spacing-md);

    &.warning {
      background: var(--color-gray-100);
      color: var(--color-red);
    }
  }
}

.amount-row {
  display: grid;

  /* there are three element of the amount row: address(es), amount number, amount symbol
     on desktop display them in a row
     but for mobile display only address(es) and put amount number and symbol below it as a single row */

  grid-template-columns: auto minmax(200px,300px) 50px;
  grid-column-gap: 10px;

  color: var(--color-gray-900);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  font-weight: var(--font-weight-normal);

  .name {
  }

  .address {
    ul {
      list-style: none;
      padding: 0;
      margin: 0;
    }
    a {
      padding-right: 5px;
    }
  }

  .large {
    max-height: 120px;
    overflow-y: auto;

    background:
            linear-gradient(var(--color-gray-50) 50%, transparent),
            linear-gradient(transparent, var(--color-gray-50) 50%),
              /* Diagonal stripes pattern */
            repeating-linear-gradient(
                            -45deg,
                            var(--color-gray-200),
                            var(--color-gray-200) 2px,
                            transparent 2px,
                            transparent 6px
            ),
            repeating-linear-gradient(
                            -45deg,
                            var(--color-gray-200),
                            var(--color-gray-200) 2px,
                            transparent 2px,
                            transparent 6px
            );

    background-position: top, bottom, top, bottom;
    background-size: 100% 24px, 100% 24px, 100% 8px, 100% 8px;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
  }

  .amount {
    text-align: right;
  }

}

@media screen and (max-width: 667px) {
  .amount-row {
    grid-template-columns: auto 50px;

    .name {
      grid-column: 1/3;
    }
  }
}

.page {
  padding-top: 90px;
}

p.disclaimer {
  color: var(--color-gray-500);
  padding-top: 100px;
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
  font-weight: var(--font-weight-normal);
}

.quick-search-form {
  width: 415px;
  margin-top: -5px;

  .query {
    width: 100%;
    height: 32px;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-sm);
    font-weight: var(--font-weight-normal);
  }
}

.search-query {
  padding: 80px 0;

  h1 {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-lg);
    font-weight: var(--font-weight-medium);

    small {
      font-size: 24px;
      line-height: calc(24px * var(--line-height-ratio));
      font-weight: var(--font-weight-normal);
    }
  }
}

.search-form {
  text-align: center;
  padding: 10px 0;
  display: grid;
  grid-template-columns: minmax(400px, auto) 150px;
}

.locale-select {
  display: grid;
  grid-template-columns: auto auto;
  gap: 30px;
  justify-content: start;
  padding-bottom: 20px;
  font-size: 14px;
  line-height: calc(14px * var(--line-height-ratio));
  font-weight: var(--font-weight-normal);

  .selector {
    position: relative;
  }

  button {
    background-color: #f0f0f0;
    border: 1px solid var(--color-gray-200);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
  }

  .dropdown {
    position: absolute;
    left: revert;
    width: 200px;
    max-height: 250px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid var(--color-gray-200);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;

    a {
      display: block;
      padding: 8px 12px;
      text-decoration: none;
      color: #333;
      font-size: 14px;
      cursor: pointer;

      &:hover {
        background-color: #f0f0f0;
      }

      &.selected {
        background-color: var(--color-gray-100);
        font-weight: var(--font-weight-semibold);
      }
    }
  }

  .currencies {
    .icon {
      padding-right: 4px;
      position: relative;
      top: 2px;
    }
    .name {
      font-weight: var(--font-weight-semibold);
    }
    .title {
      padding-left: 10px;
    }
  }

  .languages {
    width: 150px;

    .name {
      font-weight: var(--font-weight-normal);
    }
  }

  .currency, .language {
    cursor: pointer;
    padding-left: 5px;
    font-size: 14px;
    line-height: calc(14px * var(--line-height-ratio));
    font-weight: var(--font-weight-semibold);

    .icon {
      padding-right: 4px;
      position: relative;
      top: 2px;
    }
  }

  .dropdown-button {
    cursor: pointer;
    svg {
      margin-left: 5px;
    }
  }
}

.identity {
  position: relative;
  font-family: var(--font-family-mono);
  padding-right: 4px;

  .short {
    display: block;
    container-type: inline-size;
  }

  .start-inner,
  .end-inner {
    display: inline;
  }

  .ellipsis {
    cursor: pointer;
    opacity: 0.5;
    font-size: 0.5em;
    &:hover {
      opacity: 1;
    }
  }

  .copy-btn {
    position: absolute;
    right: -18px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    color: var(--color-gray-500);

    &:hover {
      color: var(--color-gray-200);
    }
  }

  &:hover .copy-btn {
    opacity: 1;
  }

  .identity-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .identity-popup {
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-500);
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    width: 80%;
    max-width: 600px;
    max-height: calc(100vh - 80px);
    overflow: auto;

    .identity-popup-content {
      font-family: var(--font-family-mono);
      font-size: 14px;
      line-height: calc(14px * var(--line-height-ratio));
      margin-bottom: 12px;
      display: flex;
      align-items: flex-start;
      gap: 4px;
    }

    .identity-popup-prefix {
      color: var(--color-gray-500);
      flex-shrink: 0;
    }

    .identity-popup-lines {
      display: flex;
      flex-direction: column;
    }

    .identity-popup-line {
      white-space: nowrap;
    }

    .identity-popup-buttons {
      display: flex;
      gap: 8px;
      justify-content: flex-end;
    }
  }

  @container (width < 400px) {
    .start-inner,
    .end-inner {
      display: none;
    }
  }

}

.page-index {
  padding-top: 100px;
}

.page-balance {

  .address-details {
    display: grid;
    grid-template-columns: 100px auto;
    padding: 20px 0;

    .avatar {
      grid-row: 1/3;
      grid-column: 1;
      height: 100px;
    }

    h2 {
      grid-row: 1;
      grid-column: 2;
      font-size: var(--font-size-md);
      line-height: var(--line-height-md);
      font-weight: var(--font-weight-medium);
    }

    .address {
      grid-row: 2;
      grid-column: 2;
      font-family: var(--font-family-mono);
      font-size: var(--font-size-sm);
      line-height: var(--line-height-sm);
      font-weight: var(--font-weight-normal);
    }
  }

  .balances {
    padding: 20px 0;
    border-top: 1px solid var(--color-gray-200);
    border-bottom: 1px solid var(--color-gray-200);
  }

  .total {
    padding: 20px 0;
    border-bottom: 1px solid var(--color-gray-200);

    .balance {
      color: var(--color-gray-900);
    }
  }
}

.address-details {
  .avatar {
    div.empty {
      border-radius: 5px;
      background-color: #a0a0a0;
      width: 80px;
      height: 80px;
      margin: 10px;
    }

    .generated {
      border-radius: 5px;
      margin: 10px;
    }
  }
}

.page-tx {

  .header {
    display: grid;
    grid-template-columns: min-content 200px auto;
    padding-bottom: 20px;

    h1 {
      font-size: var(--font-size-md);
      line-height: var(--line-height-md);
      font-weight: var(--font-weight-medium);
      padding-right: 20px;
    }

    .success {
      border: none;
      display: inline-block;
      padding: 10px 30px;
      margin: 0 5px;
      font-size: var(--font-size-sm);
      font-weight: var(--font-weight-medium);
      line-height: 26px;
      text-align: center;
      text-decoration: none;
      border-radius: 0;
      align-content: center;

      color: var(--color-gray-900);

      &.confirmed {
        background-color: var(--color-green);
      }

      &.pending {
        background-color: var(--color-gray-500);
      }

      &.not-found {
        background-color: var(--color-red);
      }
    }

  }

  .details, .tx-ethereum, .tx-bitcoin {
    padding: 20px 0;
    border-top: 1px solid var(--color-gray-200);

    .row {
      display: grid;
      grid-template-columns: 200px auto;
      color: var(--color-gray-900);
      padding-bottom: 10px;
      font-size: var(--font-size-sm);
      line-height: var(--line-height-sm);
      font-weight: var(--font-weight-normal);

      div:nth-child(2) {
        text-align: right;
      }
    }

    h2 {
      font-size: var(--font-size-md);
      line-height: var(--line-height-md);
      font-weight: var(--font-weight-medium);
    }
  }

  .tx-ethereum {
  }
}

@media screen and (max-width: 667px) {
  .page-tx {
    .tx-ethereum {
      display: grid;
      grid-template-rows: auto;
    }
  }
}

.tx-bitcoin {
  .changes {
    h2 {
      border-bottom: 1px solid var(--color-gray-200);
    }
  }
}
