/* theme.css — layout + BEM components for the Otto landing page.
   Consumes tokens from base.css. Replaces the compiled Tailwind build. */

/* ---------------------------------------------------------------- layout */

@layer layout {
  .page {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background);
    font-family: var(--font-sans);
  }

  .container {
    max-width: var(--container-max);
    margin-inline: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  @media (min-width: 768px) {
    .container {
      border-inline: 1px solid var(--color-border);
    }
  }
}

/* ------------------------------------------------------------ components */

@layer components {
  /* ---- shared atoms ---- */

  .btn {
    display: inline-block;
    width: fit-content;
    padding: 10px 20px;
    background: var(--color-foreground);
    color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: var(--weight-medium);
    transition: opacity var(--duration-fast);
    cursor: pointer;
  }

  .btn:hover {
    opacity: 0.8;
  }

  .btn--nav {
    padding: 6px 16px;
    font-size: var(--text-body-sm);
    letter-spacing: var(--tracking-body);
    box-shadow: var(--shadow-button);
  }

  .arrow-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-foreground);
    box-shadow: var(--shadow-button);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-base);
    cursor: pointer;
  }

  .arrow-btn:hover {
    border-color: var(--color-muted);
    background: var(--color-surface-hover);
  }

  .arrow-btn svg {
    width: 16px;
    height: 16px;
  }

  .tag {
    width: fit-content;
    font-size: 10px;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 4px 10px;
  }

  .dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    background: var(--color-border-strong);
  }

  .dot--on {
    background: var(--color-emerald-400);
  }

  /* ---- nav ---- */

  .nav {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--color-border);
    background: rgb(from var(--color-background) r g b / 0.7);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
  }

  .nav__inner {
    height: 52px;
    display: flex;
    align-items: center;
    padding-inline: 24px;
    gap: 24px;
  }

  .nav__logo {
    display: flex;
    align-items: center;
  }

  .nav__logo svg {
    height: 14px;
    width: auto;
    color: var(--color-foreground);
  }

  .nav__wordmark {
    font-size: 17px;
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-display);
    color: var(--color-foreground);
  }

  .nav__links {
    display: none;
    align-items: center;
    gap: 24px;
  }

  .nav__link {
    font-size: var(--text-body-sm);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-body);
    color: var(--color-muted);
    transition: color var(--duration-fast);
  }

  .nav__link:hover {
    color: var(--color-foreground);
  }

  .nav__actions {
    display: none;
    margin-left: auto;
    align-items: center;
    gap: 8px;
  }

  .nav__mobile {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .nav__burger {
    width: 32px;
    height: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
  }

  .nav__burger span {
    display: block;
    width: 20px;
    height: 1.5px;
    background: var(--color-foreground);
    transition: all var(--duration-slow);
  }

  /* mobile dropdown menu */
  .nav__menu {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px 24px 16px;
    border-top: 1px solid var(--color-border);
  }

  .nav__menu .nav__link {
    padding-block: 8px;
  }

  @media (max-width: 767.98px) {
    .nav--open .nav__menu {
      display: flex;
    }
  }

  .nav--open .nav__burger span:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .nav--open .nav__burger span:nth-child(2) {
    opacity: 0;
  }

  .nav--open .nav__burger span:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }

  @media (min-width: 768px) {
    .nav__inner {
      padding-inline: 32px;
      gap: 32px;
    }

    .nav__links,
    .nav__actions {
      display: flex;
    }

    .nav__mobile {
      display: none;
    }
  }

  /* ---- hero ---- */

  .hero {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
    padding: 80px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
  }

  /* molten glow rising from the bottom edge — the foundry at work */
  .hero__melt {
    pointer-events: none;
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 70%;
    background:
      radial-gradient(
        60% 55% at 50% 100%,
        color-mix(in srgb, #ff9d47 30%, transparent),
        transparent 70%
      ),
      radial-gradient(
        120% 85% at 50% 100%,
        color-mix(in srgb, var(--color-emerald-400) 22%, transparent),
        transparent 62%
      );
    opacity: 0.5;
  }

  :root[data-theme="dark"] .hero__melt {
    opacity: 0.75;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hero__melt {
      opacity: 0.75;
    }
  }

  .hero__content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both reveal-load;
  }

  .hero__mark {
    width: 44px;
    height: auto;
    color: var(--color-foreground);
  }

  .hero__title {
    font-size: var(--text-hero);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-display);
    color: var(--color-foreground);
    max-width: 45rem;
  }

  .hero__lede {
    font-size: var(--text-body-md);
    font-weight: var(--weight-medium);
    line-height: 1.6;
    letter-spacing: var(--tracking-body);
    color: var(--color-muted);
    max-width: 30rem;
  }

  .hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }

  .code-pill {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 9px 16px;
    background: var(--color-surface);
    transition: color var(--duration-fast), border-color var(--duration-fast);
  }

  .code-pill:hover {
    color: var(--color-foreground);
    border-color: var(--color-border-strong);
  }

  @media (min-width: 768px) {
    .hero {
      padding-block: 112px;
    }

    .hero__title {
      font-size: var(--text-hero-md);
    }

    .hero__lede {
      font-size: var(--text-body-lg);
    }
  }

  /* ---- subpage hero ---- */

  .subhero {
    border-bottom: 1px solid var(--color-border);
    padding: 64px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    animation: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both reveal-load;
  }

  .subhero__title {
    font-size: var(--text-hero);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-display);
    color: var(--color-foreground);
  }

  @media (min-width: 768px) {
    .subhero {
      padding-block: 96px;
    }
  }

  @keyframes reveal-load {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .hero__content,
    .features {
      animation: none;
    }
  }

  /* ---- feature grid ---- */

  .features {
    display: grid;
    grid-template-columns: 1fr;
    border-bottom: 1px solid var(--color-border);
    animation: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both reveal-load;
  }

  .feature {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
    padding: 32px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
  }

  .feature__body {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .feature__body--intro {
    gap: 16px;
  }

  .feature__title {
    font-size: var(--text-h2);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-heading);
    letter-spacing: var(--tracking-display);
    color: var(--color-foreground);
  }

  .feature__title--lead {
    font-size: 30px;
    line-height: 1.08;
  }

  .feature__text {
    font-size: var(--text-body-sm);
    font-weight: var(--weight-medium);
    line-height: var(--leading-body);
    letter-spacing: var(--tracking-body);
    color: var(--color-muted);
  }

  .feature__text--lead {
    font-size: var(--text-body-md);
  }

  /* decorative embeds pinned to the card bottom */
  .feature__deco {
    pointer-events: none;
    position: absolute;
    inset-inline: 0;
    bottom: 0;
  }

  .feature__deco--pad {
    padding: 0 32px 32px;
  }

  .feature__deco--fade-55 {
    user-select: none;
    padding: 0 32px 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    mask-image: linear-gradient(to bottom, transparent 0%, black 55%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 55%);
  }

  .feature__deco--fade-45 {
    mask-image: linear-gradient(to bottom, transparent 0%, black 45%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 45%);
  }

  .feature__deco--fade-40 {
    padding: 0 32px 32px;
    mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 40%);
  }

  @media (min-width: 768px) {
    .features {
      grid-template-columns: repeat(3, 1fr);
    }

    .feature {
      padding: 40px;
    }

    .feature--divide {
      border-right: 1px solid var(--color-border);
    }

    .features .feature:nth-child(n + 4) {
      border-bottom: 0;
    }

    .feature__deco--pad,
    .feature__deco--fade-55,
    .feature__deco--fade-40 {
      padding-inline: 40px;
    }

    .feature__title--lead {
      font-size: 34px;
    }
  }

  /* file tree (Runtime card) */
  .filetree {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 2.1;
    color: var(--color-border-strong);
  }

  /* model list (Gateway card) */
  .model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--color-border);
    background: var(--color-background);
    padding: 12px 32px;
  }

  .model-row__id {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .model-row__name {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-foreground);
  }

  .model-row__kind {
    font-size: 10px;
    color: var(--color-muted);
  }

  @media (min-width: 768px) {
    .model-row {
      padding-inline: 40px;
    }
  }

  /* connector chips (Passkey card) */
  .conn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .conn {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-background);
    padding: 8px 10px;
  }

  .conn__name {
    font-size: 11px;
    font-weight: var(--weight-medium);
    color: var(--color-foreground);
  }

  .conn .dot {
    margin-left: auto;
  }

  /* identity card */
  .id-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .id-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .id-card__avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
  }

  .id-card__name {
    font-size: 12px;
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-body);
    color: var(--color-foreground);
  }

  .id-card__status {
    margin-left: auto;
    font-size: 10px;
    font-weight: var(--weight-medium);
    color: var(--color-emerald-600);
  }

  .id-card__rule {
    height: 1px;
    background: var(--color-border);
  }

  .id-card__row {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .id-card__row svg {
    width: 12px;
    height: 12px;
    color: var(--color-muted);
    flex-shrink: 0;
  }

  .id-card__value {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--color-foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* spend card */
  .spend-card {
    border-radius: var(--radius-2xl);
    background: #1a1a1a;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  }

  .spend-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .spend-card__number {
    font-size: 10px;
    font-weight: var(--weight-medium);
    letter-spacing: 0.12em;
    color: #666;
  }

  .spend-card__head svg {
    width: 16px;
    height: auto;
    color: #3a3a3a;
  }

  .spend-card__meter {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .spend-card__amounts {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .spend-card__spent {
    font-size: 15px;
    font-weight: var(--weight-semibold);
    letter-spacing: -0.025em;
    color: var(--color-white);
  }

  .spend-card__limit {
    font-size: 10px;
    color: #444;
  }

  .spend-card__track {
    height: 3px;
    border-radius: var(--radius-full);
    background: #2a2a2a;
    overflow: hidden;
  }

  .spend-card__fill {
    height: 100%;
    width: 22%;
    border-radius: var(--radius-full);
    background: var(--color-emerald-400);
  }

  /* ---- duo row (manage / agent computer) ---- */

  .duo {
    display: grid;
    grid-template-columns: 1fr;
    border-bottom: 1px solid var(--color-border);
  }

  .duo__panel {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
    padding: 32px;
    display: flex;
    flex-direction: column;
    min-height: 300px;
  }

  .duo__panel--wide {
    border-bottom: 0;
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 32px;
  }

  .duo__body {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .duo__body--device {
    gap: 16px;
  }

  .duo__text--narrow {
    max-width: 17.5rem;
  }

  /* stacked phone notifications */
  .notif-stack {
    pointer-events: none;
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 0 32px 32px;
    mask-image: linear-gradient(to bottom, transparent 0%, black 35%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 35%);
  }

  .notif {
    position: relative;
    z-index: 10;
    padding: 12px 14px;
    border-radius: var(--radius-2xl);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent);
    backdrop-filter: blur(var(--blur-md));
    border: 1px solid color-mix(in srgb, var(--color-foreground) 9%, transparent);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 12px;
  }

  .notif__icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--color-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .notif__icon svg {
    width: 14px;
    height: auto;
    color: var(--color-background);
  }

  .notif__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .notif__meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .notif__app {
    font-size: 11px;
    font-weight: var(--weight-semibold);
    color: var(--color-foreground);
  }

  .notif__time {
    font-size: 10px;
    color: var(--color-muted);
    flex-shrink: 0;
  }

  .notif__body {
    font-size: 11px;
    line-height: 1.45;
    color: var(--color-muted);
  }

  .notif-stack__ghost {
    position: relative;
    z-index: 0;
    margin-inline: 12px;
    height: 20px;
    margin-top: -10px;
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    background: color-mix(in srgb, var(--color-surface) 78%, transparent);
    backdrop-filter: blur(var(--blur-md));
    border: 1px solid color-mix(in srgb, var(--color-foreground) 7%, transparent);
    border-top: 0;
  }

  .notif-stack__ghost--far {
    z-index: -1;
    margin-inline: 24px;
    background: color-mix(in srgb, var(--color-surface) 58%, transparent);
    border-color: color-mix(in srgb, var(--color-foreground) 5%, transparent);
  }

  /* device tile */
  .device-tile {
    flex-shrink: 0;
    width: 160px;
    height: 160px;
    background: #1a1a1a;
    border-radius: var(--radius-3xl);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .device-tile svg {
    width: 40px;
    height: auto;
    color: #444;
  }

  @media (min-width: 640px) {
    .duo__panel--wide {
      flex-direction: row;
      align-items: center;
    }
  }

  @media (min-width: 768px) {
    .duo {
      grid-template-columns: 1fr 1fr;
    }

    .duo__panel {
      padding: 40px;
      border-bottom: 0;
      border-right: 1px solid var(--color-border);
    }

    .duo__panel--wide {
      border-right: 0;
      gap: 40px;
      justify-content: center;
    }

    .notif-stack {
      padding-inline: 40px;
    }

    .device-tile {
      width: 200px;
      height: 200px;
      border-radius: 28px;
    }
  }

  /* ---- footer ---- */

  .footer {
    margin-top: auto;
    padding: 40px 32px;
  }

  .footer__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }

  .footer__col {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .footer__heading {
    font-size: 10px;
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--color-muted);
    transition: color var(--duration-fast);
  }

  a.footer__heading:hover {
    color: var(--color-foreground);
  }

  .footer__link {
    font-size: var(--text-body-sm);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-body);
    color: var(--color-muted);
    transition: color var(--duration-fast);
  }

  .footer__link:hover {
    color: var(--color-foreground);
  }

  .footer__bottom {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
  }

  .footer__meta {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .footer__copy {
    font-size: 11px;
    letter-spacing: var(--tracking-body);
    color: var(--color-muted);
    text-align: center;
  }

  .footer__social {
    display: inline-flex;
    color: var(--color-muted);
    transition: color var(--duration-fast);
  }

  .footer__social:hover {
    color: var(--color-foreground);
  }

  /* theme switcher — same component as platform/ui */
  .theme-switch {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 3px;
    margin: 0;
    background: var(--color-background);
  }

  .theme-switch__option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 12px;
    color: var(--color-muted);
    transition: background var(--duration-base), color var(--duration-base);
    white-space: nowrap;
  }

  .theme-switch__option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
  }

  .theme-switch__option:has(input:checked) {
    background: var(--color-surface);
    color: var(--color-foreground);
    box-shadow: var(--shadow-button);
  }

  .theme-switch__option svg {
    flex-shrink: 0;
  }

  .theme-switch__option span {
    line-height: 1;
  }

  @media (min-width: 640px) {
    .footer__bottom {
      flex-direction: row;
      justify-content: space-between;
      gap: 24px;
    }
  }

  @media (min-width: 768px) {
    .footer__grid {
      grid-template-columns: repeat(4, 1fr);
    }
  }
}
