@import url("https://fonts.googleapis.com/css2?family=Geist:wght@100..900&display=swap");
@import url("https://unpkg.com/normalize.css") layer(normalize);
@layer normalize, base, components, utilities, text-effect, snap, responsive;

@layer base {
  :root {
    --ink: #0f1111;
    --muted: #5c6366;
    --panel: #ffffff;
    --line: rgba(15, 17, 17, 0.12);
    --accent: #0f766e;
    --accent-warm: #c77d1d;
    --shadow: 0 20px 40px rgba(15, 17, 17, 0.12);
    --landing-shift-x: 2.5ch;
    --landing-shift-y: 2em;
    --landing-first-hero-height: 60vh;
    --landing-last-hero-height: 50vh;
    --landing-footer-gap: 20vh;
    --list-text-shift-x: 0ch;
    --account-offset-x: 150px;
    --account-offset-y: 18px;
    --account-font-size: 1.5rem;
    --account-icon-size: 29px;
    --list-color-1: oklch(65% 0.3 0);
    --list-color-2: oklch(65% 0.3 24);
    --list-color-3: oklch(65% 0.3 48);
    --list-color-4: oklch(65% 0.3 72);
    --list-color-5: oklch(65% 0.3 96);
    --list-color-6: oklch(65% 0.3 120);
  }

  html,
  body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    font-family: "Geist", system-ui, sans-serif;
    color: var(--ink);
    background-color: #f7f6f2;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;

    --dot-color: rgba(0, 0, 0, 0.15);
    --spacing: 24px;
    --dot-size: 1.5px;

    background-image: radial-gradient(
      var(--dot-color) var(--dot-size),
      transparent var(--dot-size)
    );
    background-size: var(--spacing) var(--spacing);
    background-position: top left;
    background-repeat: repeat;

    mask-image: radial-gradient(circle at top left, #000 0%, transparent 75%);
    mask-size: 100% 100%;
    mask-repeat: no-repeat;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  [hidden] {
    display: none !important;
  }

  button {
    font-family: inherit;
  }

  img {
    max-width: 100%;
    display: block;
  }

  h1,
  h2,
  h3 {
    margin: 0;
    font-weight: 700;
  }

  body.utility,
  body.vault {
    scroll-snap-type: none;
    scroll-behavior: auto;
  }

  html.landing,
  body.landing {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
  }
}

@layer components {
  .no-offset {
    margin: 0;
  }

  .container {
    width: 100%;
    max-width: 1024px;
    padding: 0 16px;
    margin: 0 auto;
  }

  .shell {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 120px 16px;
  }

  .utility .container,
  .vault .container {
    padding: 80px 16px 120px;
  }

  .hero {
    height: 100vh;
    display: flex;
    align-items: center;
  }

  .landing .hero {
    height: 100vh;
    align-items: center;
    padding-top: 0;
  }

  .landing main > .hero:last-of-type {
    height: var(--landing-last-hero-height);
  }

  .utility .hero,
  .vault .hero {
    height: auto;
    padding: 40px 0 20px;
    align-items: flex-start;
  }

  .hero-text {
    font-size: clamp(4rem, 8vw, 8rem);
    font-weight: 800;
  }

  .landing .hero-text {
    white-space: pre-line;
  }

  .hero-description {
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 400;
    margin-top: 16px;
    color: var(--muted);
  }

  .landing .hero-description {
    color: var(--ink);
  }

  .landing main > .hero:first-of-type > div,
  .landing main > .hero:last-of-type > div,
  .landing main > .list-container {
    position: relative;
  }

  .landing main > .hero:first-of-type > div {
    left: calc(-1 * var(--landing-shift-x));
    top: calc(-1 * var(--landing-shift-y));
  }

  .landing .hero-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
  }

  .landing .hero-copy {
    max-width: 640px;
  }

  .landing .hero-row .account-ui {
    transform: translate(var(--account-offset-x), var(--account-offset-y));
  }

  .landing main > .hero:first-of-type {
    height: var(--landing-first-hero-height);
  }

  .landing main > .list-container {
    left: calc(-1 * var(--landing-shift-x));
  }

  .landing main > .hero:first-of-type,
  .landing main > .hero:last-of-type {
    scroll-snap-align: start;
  }

  .landing main > .hero:last-of-type > div {
    left: calc(-1 * var(--landing-shift-x));
  }

  .scan-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 12px;
  }

  .list-text {
    font-size: clamp(2.5rem, 6vw, 6rem);
    font-weight: 600;
    position: sticky;
    top: calc(50% - 0.5lh);
    align-self: flex-start;
    min-width: max-content;
    transform: translateX(var(--list-text-shift-x));
  }

  .list {
    font-size: clamp(2.5rem, 6vw, 6rem);
    font-weight: 600;
    list-style-type: none;
    padding: 0;
  }

  .list li {
    line-height: 1.25;
    cursor: default;
  }

  .list li.is-active {
    cursor: pointer;
  }

  .list-container {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 48px;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    position: sticky;
    top: 0;
    background: rgba(247, 246, 242, 0.85);
    backdrop-filter: blur(12px);
    z-index: 20;
  }

  .account-ui {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: var(--account-font-size);
    font-weight: 600;
    color: var(--ink);
  }

  .account-ui[hidden] {
    display: none;
  }

  .account-name {
    font-size: inherit;
    font-weight: 600;
  }

  .account-icon {
    width: var(--account-icon-size);
    height: auto;
  }

  .back-link {
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
  }

  .card,
  .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 28px;
  }

  .scan-card {
    max-width: 760px;
    margin: 0 auto;
  }

  .upload-form {
    display: grid;
    gap: 18px;
  }

  .field {
    display: grid;
    gap: 8px;
  }

  .label {
    font-weight: 600;
  }

  .text-input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    font-size: 1rem;
  }

  .dropzone {
    border: 2px dashed rgba(15, 17, 17, 0.2);
    border-radius: 18px;
    padding: 24px;
    display: grid;
    gap: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.7);
  }

  .dropzone.is-dragover {
    border-color: var(--ink);
    background: rgba(15, 17, 17, 0.06);
  }

  .dropzone input {
    display: none;
  }

  .file-name {
    color: var(--muted);
    font-family: "Geist", system-ui, sans-serif;
  }

  .primary-btn {
    background: var(--ink);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 14px 24px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(15, 17, 17, 0.2);
  }

  .ghost-btn {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    border-radius: 999px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
  }

  .select-toggle {
    border-radius: 14px;
    padding: 10px 20px;
    min-width: 110px;
  }

  .select-toggle.is-active {
    border-color: var(--ink);
    box-shadow: 0 0 0 2px var(--ink);
  }

  .result {
    margin-top: 28px;
  }

  .result-card {
    display: grid;
    gap: 16px;
    align-items: center;
    text-align: center;
  }

  .result-card img {
    width: min(320px, 80vw);
    margin: 0 auto;
  }

  .link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
  }

  .link-row input {
    flex: 1;
    min-width: 240px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
  }

  .form-grid {
    display: grid;
    gap: 16px;
  }

  .field {
    display: grid;
    gap: 8px;
  }

  .field input,
  .field select,
  #access-form input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    font-size: 1rem;
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(15, 17, 17, 0.08);
    font-size: 0.9rem;
    color: var(--muted);
  }

  .spinner {
    display: flex;
    gap: 6px;
  }

  .spinner span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink);
    opacity: 0.2;
    animation: pulse 1.2s infinite;
  }

  .spinner span:nth-child(2) {
    animation-delay: 0.2s;
  }

  .spinner span:nth-child(3) {
    animation-delay: 0.4s;
  }

  .approved,
  .denied,
  .waiting {
    margin-top: 24px;
    display: grid;
    gap: 12px;
  }

  .zip-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
    font-size: 0.9rem;
  }

  .meta {
    color: var(--muted);
  }

  .hint {
    color: var(--muted);
    font-size: 0.9rem;
  }

  .modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 17, 0.35);
    display: grid;
    place-items: center;
    z-index: 50;
  }

  .modal[hidden] {
    display: none;
  }

  .modal-card {
    background: var(--panel);
    border-radius: 22px;
    border: 1px solid var(--line);
    padding: 28px;
    width: min(420px, 90vw);
    display: grid;
    gap: 14px;
    box-shadow: var(--shadow);
  }

  .modal-message {
    white-space: pre-line;
  }

  .modal-card input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
  }

  .modal-actions {
    display: flex;
    justify-content: flex-end;
  }

  .vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    min-height: 70vh;
    margin-bottom: 80px;
  }

  .vault-slot {
    background: linear-gradient(145deg, #f5f4ee, #ffffff);
    border: 1px solid rgba(15, 17, 17, 0.15);
    border-radius: 16px;
    min-height: 110px;
    display: flex;
    align-items: flex-end;
    padding: 14px;
    position: relative;
    box-shadow: inset 0 0 0 2px rgba(15, 17, 17, 0.04);
  }

  .vault-slot.is-filled {
    cursor: pointer;
  }

  .selection-mode .vault-slot.is-filled {
    cursor: pointer;
  }

  .vault-slot.is-selected {
    border-color: var(--ink);
    box-shadow: inset 0 0 0 2px rgba(15, 17, 17, 0.12), 0 0 0 2px var(--ink);
  }

  .vault-slot::before {
    content: "";
    position: absolute;
    top: 12px;
    left: 14px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(15, 17, 17, 0.2);
  }

  .vault-label {
    font-size: 0.95rem;
    font-weight: 600;
  }

  .language-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
  }

  .language-btn {
    border: 1px solid var(--line);
    background: transparent;
    padding: 14px 18px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
  }

  .language-btn.is-active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
  }

  .lang-picker {
    display: none !important;
  }
}

@layer utilities {
  .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0 0 10px;
  }

  .subtitle,
  .small {
    color: var(--muted);
  }

  .muted {
    color: var(--muted);
  }

  .error-msg {
    color: #b9473b;
    font-weight: 600;
  }

  .is-error {
    border-color: #b9473b;
  }
}

@layer text-effect {
  :root {
    --count: 6;
    --end: 360;
    --step: calc(var(--end) / var(--count));
  }

  .list li:nth-child(1) {
    color: var(--list-color-1);
  }

  .list li:nth-child(2) {
    color: var(--list-color-2);
  }

  .list li:nth-child(3) {
    color: var(--list-color-3);
  }

  .list li:nth-child(4) {
    color: var(--list-color-4);
  }

  .list li:nth-child(5) {
    color: var(--list-color-5);
  }

  .list li:nth-child(6) {
    color: var(--list-color-6);
  }

  @supports (animation-timeline: scroll()) and (animation-range: 0% 100%) {
    .list li:first-of-type {
      --start-opacity: 1;
    }

    .list li:last-of-type {
      --end-opacity: 1;
    }

    .list li {
      opacity: 0.2;
      animation-name: brighten;
      animation-fill-mode: both;
      animation-timing-function: linear;

      animation-timeline: view();
      animation-range: cover calc(50% - 1lh) calc(50% + 1lh);
    }

    @keyframes brighten {
      0% {
        opacity: var(--start-opacity, 0.2);
      }

      50% {
        opacity: 1;
      }

      100% {
        opacity: var(--end-opacity, 0.2);
      }
    }
  }
}

@layer snap {
  html,
  body {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
  }

  .list li {
    scroll-snap-align: center;
  }

  html.landing .list li,
  body.landing .list li {
    scroll-snap-align: center;
  }
}

@layer responsive {
  @media (max-width: 600px) {
    .list-container {
      column-gap: 12px;
    }
  }
}

.landing footer {
  text-align: center;
  margin-top: var(--landing-footer-gap);
  padding-bottom: 24px;
  scroll-snap-align: end;
  scroll-snap-stop: normal;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.8;
  }
}
