@layer reset, base, layout, components, states;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p { margin: 0; }
  button, input { font: inherit; }
}

@layer base {
  :root {
    color-scheme: light;
    --cream: #f5f0e6;
    --paper: #fbf8f1;
    --ink: #092a35;
    --muted: #60747a;
    --line: rgba(9, 42, 53, 0.14);
    --sea: #0a5265;
    --deep: #062631;
    --sun: #f1b95b;
    --white: #fffaf0;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
  }

  body {
    min-width: 320px;
    overflow-x: clip;
    color: var(--ink);
    background: var(--cream);
  }

  a { color: inherit; }
  button, a { -webkit-tap-highlight-color: transparent; }
  button { color: inherit; }
  :focus-visible { outline: 2px solid #d99229; outline-offset: 4px; }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .skip-link {
    position: fixed;
    z-index: 100;
    top: 1rem;
    left: 1rem;
    padding: 0.8rem 1rem;
    color: var(--ink);
    background: var(--white);
    border-radius: 999px;
    transform: translateY(-180%);
    transition: transform 180ms ease;
  }

  .skip-link:focus { transform: translateY(0); }
}

@layer layout {
  .header {
    position: absolute;
    z-index: 10;
    top: 0;
    left: 0;
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: max(1.35rem, env(safe-area-inset-top)) clamp(1.2rem, 4vw, 4.8rem) 1rem;
    color: var(--white);
  }

  .header nav {
    display: flex;
    gap: 0.75rem;
    align-items: center;
  }

  .hero {
    position: relative;
    min-height: min(48rem, 82svh);
    overflow: hidden;
    color: var(--white);
    background:
      radial-gradient(circle at 16% 14%, rgba(255, 220, 151, 0.2), transparent 28%),
      linear-gradient(145deg, #133d4d 0%, #0a5265 52%, #08738a 100%);
  }

  .hero__content {
    position: relative;
    z-index: 2;
    display: flex;
    min-height: inherit;
    max-width: 90rem;
    margin: 0 auto;
    padding: clamp(8.5rem, 19vh, 12rem) clamp(1.2rem, 6vw, 6rem) clamp(7rem, 15vh, 10rem);
    flex-direction: column;
    justify-content: center;
  }

  .hero__meta {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: clamp(2rem, 5vh, 3.5rem);
  }

  .hero__meta > p:first-child {
    max-width: 34rem;
    color: rgba(255, 250, 240, 0.72);
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.6;
  }

  .hero__count {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    flex: 0 0 auto;
  }

  .hero__count strong {
    color: var(--sun);
    font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
    font-size: clamp(3rem, 5vw, 5.2rem);
    font-weight: 400;
    letter-spacing: -0.07em;
    line-height: 0.8;
  }

  .hero__count span {
    color: rgba(255, 250, 240, 0.66);
    font-size: 0.68rem;
    font-weight: 720;
    letter-spacing: 0.12em;
    line-height: 1.45;
    text-transform: uppercase;
  }

  .catalog {
    position: relative;
    background: var(--cream);
  }

  .catalog__inner {
    max-width: 90rem;
    margin: 0 auto;
    padding: clamp(4rem, 8vw, 8rem) clamp(1.2rem, 5vw, 5rem);
  }

  .catalog__intro {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 2rem;
  }

  .catalog-tools {
    position: sticky;
    z-index: 5;
    top: 0;
    margin: 0 calc(clamp(1.2rem, 5vw, 5rem) * -1) 2rem;
    padding: 0.8rem clamp(1.2rem, 5vw, 5rem) 1rem;
    background: color-mix(in srgb, var(--cream) 88%, transparent);
    border-bottom: 1px solid transparent;
    backdrop-filter: blur(18px) saturate(1.2);
  }

  .catalog-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.8rem, 1.6vw, 1.35rem);
  }

  .catalog-cta {
    display: flex;
    gap: 3rem;
    align-items: flex-end;
    justify-content: space-between;
    padding: clamp(4.5rem, 9vw, 9rem) clamp(1.2rem, 7vw, 8rem);
    color: var(--white);
    background:
      radial-gradient(circle at 80% 10%, rgba(97, 184, 190, 0.22), transparent 28%),
      var(--deep);
  }

  footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1.7rem clamp(1.2rem, 4vw, 4.8rem);
    color: rgba(255, 250, 240, 0.7);
    background: #041b24;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
  }

  footer > a:last-child { justify-self: end; }
}

@layer components {
  .brand {
    display: inline-flex;
    align-items: baseline;
    font-size: clamp(1.05rem, 1.45vw, 1.5rem);
    font-weight: 760;
    letter-spacing: -0.05em;
    text-decoration: none;
  }

  .brand i {
    width: 0.27em;
    height: 0.27em;
    margin: 0 0.12em 0.07em;
    overflow: hidden;
    color: transparent;
    background: var(--sun);
    border-radius: 50%;
    box-shadow: 0 0 0 0.28rem rgba(241, 185, 91, 0.14);
  }

  .brand--footer { color: var(--white); }

  .back-link,
  .creator-link {
    display: inline-flex;
    gap: 0.55rem;
    align-items: center;
    min-height: 2.65rem;
    padding: 0.7rem 0.9rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 720;
    letter-spacing: 0.08em;
    text-decoration: none;
    text-transform: uppercase;
    transition: transform 180ms ease, color 180ms ease, background 180ms ease;
  }

  .back-link { color: rgba(255, 250, 240, 0.75); }
  .creator-link { color: var(--ink); background: var(--white); }
  .back-link:hover { color: var(--white); }
  .creator-link:hover { background: var(--sun); transform: translateY(-2px); }

  .back-link svg,
  .creator-link svg,
  .catalog-cta a svg,
  .load-more svg {
    width: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
  }

  .eyebrow {
    margin-bottom: 0.85rem;
    color: var(--sun);
    font-size: 0.7rem;
    font-weight: 780;
    letter-spacing: 0.2em;
    text-transform: uppercase;
  }

  .eyebrow--dark { color: #b4711d; }

  .hero h1,
  .catalog h2,
  .catalog-cta h2 {
    font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
    font-weight: 400;
    letter-spacing: -0.06em;
    line-height: 0.92;
    text-wrap: balance;
  }

  .hero h1 { max-width: 11ch; font-size: clamp(4rem, 8.6vw, 10rem); }
  .catalog h2 { font-size: clamp(2.8rem, 5vw, 5.8rem); }
  .catalog-cta h2 { font-size: clamp(3rem, 6vw, 7rem); }

  .hero__orb {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    pointer-events: none;
  }

  .hero__orb--one { top: 17%; right: -8rem; width: 30rem; height: 30rem; }
  .hero__orb--two { right: 13rem; bottom: 8rem; width: 8rem; height: 8rem; }

  .hero__wave {
    position: absolute;
    right: -5%;
    bottom: -1px;
    left: -5%;
    height: clamp(4rem, 10vw, 8rem);
    background: var(--cream);
    border-radius: 50% 50% 0 0 / 38% 38% 0 0;
  }

  .result-count {
    padding-bottom: 0.65rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 680;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .result-count strong { color: var(--ink); font-size: 1rem; }

  .search {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 4rem;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    box-shadow: 0 0.7rem 2rem rgba(9, 42, 53, 0.04);
    transition: border-color 180ms ease, box-shadow 180ms ease;
  }

  .search:focus-within {
    border-color: rgba(10, 82, 101, 0.55);
    box-shadow: 0 0 0 4px rgba(10, 82, 101, 0.08);
  }

  .search > svg {
    width: 1.25rem;
    margin-left: 1.2rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 1.6;
  }

  .search input {
    width: 100%;
    height: 100%;
    padding: 0 1rem;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 1rem;
  }

  .search input::placeholder { color: #849397; }

  .search kbd {
    margin-right: 0.9rem;
    padding: 0.25rem 0.45rem;
    color: #7b8c91;
    background: #ece7dc;
    border: 1px solid rgba(9, 42, 53, 0.1);
    border-radius: 0.4rem;
    font-size: 0.7rem;
    box-shadow: 0 1px 0 rgba(9, 42, 53, 0.08);
  }

  .filters {
    display: flex;
    gap: 0.55rem;
    margin-top: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .filters::-webkit-scrollbar { display: none; }

  .filter {
    flex: 0 0 auto;
    padding: 0.65rem 0.9rem;
    color: #52696f;
    background: transparent;
    border: 1px solid rgba(9, 42, 53, 0.16);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 710;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
  }

  .filter:hover { border-color: rgba(9, 42, 53, 0.4); }
  .filter.is-active { color: var(--white); background: var(--ink); border-color: var(--ink); }

  .c {
    position: relative;
    display: grid;
    min-width: 0;
    min-height: 13.5rem;
    padding: 1.15rem;
    overflow: hidden;
    color: var(--ink);
    background: var(--card-bg, #dde9e8);
    border: 1px solid rgba(9, 42, 53, 0.1);
    border-radius: 1.4rem;
    text-decoration: none;
    transform: translateY(0);
    transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 240ms ease;
  }

  .c:hover {
    z-index: 1;
    box-shadow: 0 1.3rem 3rem rgba(9, 42, 53, 0.13);
    transform: translateY(-0.35rem);
  }

  .c::before {
    position: absolute;
    top: -4.5rem;
    right: -3.5rem;
    width: 11rem;
    height: 11rem;
    background: rgba(255, 255, 255, 0.26);
    border-radius: 50%;
    content: "";
  }

  .c::after {
    position: absolute;
    right: 1.15rem;
    bottom: 1.15rem;
    width: 1.9rem;
    height: 1.9rem;
    background: rgba(255, 255, 255, 0.5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10h11M11 5l5 5-5 5' fill='none' stroke='%23092a35' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 1rem no-repeat;
    border-radius: 50%;
    content: "";
    transition: transform 180ms ease, background-color 180ms ease;
  }

  .c:hover::after { background-color: var(--white); transform: translateX(0.18rem); }

  .c[data-category="food"] { --card-bg: #f1d8ae; }
  .c[data-category="beauty"] { --card-bg: #edd5d4; }
  .c[data-category="health"] { --card-bg: #d8e7df; }
  .c[data-category="auto"] { --card-bg: #d5dee4; }
  .c[data-category="other"] { --card-bg: #e8e0cf; }

  .card-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  .card-index {
    color: rgba(9, 42, 53, 0.48);
    font-size: 0.64rem;
    font-variant-numeric: tabular-nums;
    font-weight: 760;
    letter-spacing: 0.1em;
  }

  .card-category {
    padding: 0.35rem 0.55rem;
    color: rgba(9, 42, 53, 0.68);
    background: rgba(255, 255, 255, 0.36);
    border-radius: 999px;
    font-size: 0.58rem;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .card-copy {
    position: relative;
    z-index: 1;
    align-self: end;
    padding: 3rem 3rem 0 0;
  }

  .card-name {
    display: -webkit-box;
    overflow: hidden;
    font-family: Iowan Old Style, Baskerville, "Times New Roman", serif;
    font-size: clamp(1.55rem, 2.2vw, 2.25rem);
    font-weight: 400;
    letter-spacing: -0.045em;
    line-height: 0.98;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .card-domain {
    display: block;
    margin-top: 0.6rem;
    overflow: hidden;
    color: rgba(9, 42, 53, 0.54);
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .load-more {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    justify-content: center;
    margin: 2.5rem auto 0;
    padding: 0.9rem 1.15rem;
    color: var(--white);
    background: var(--ink);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 740;
  }

  .empty-state {
    padding: 5rem 1rem;
    text-align: center;
  }

  .empty-state > span {
    display: block;
    margin-bottom: 0.8rem;
    color: var(--sea);
    font-family: Georgia, serif;
    font-size: 4rem;
  }

  .empty-state h3 { font: 400 2.5rem/1 Iowan Old Style, Baskerville, serif; }
  .empty-state p { margin-top: 0.7rem; color: var(--muted); }
  .empty-state button {
    margin-top: 1.2rem;
    padding: 0.65rem 0.85rem;
    color: var(--white);
    background: var(--ink);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
  }

  .catalog-cta a {
    display: inline-flex;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    min-width: min(100%, 19rem);
    padding: 1.05rem 1.15rem 1.05rem 1.35rem;
    color: var(--ink);
    background: var(--white);
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 760;
    text-decoration: none;
    transition: background 180ms ease, transform 180ms ease;
  }

  .catalog-cta a:hover { background: var(--sun); transform: translateY(-2px); }
  footer a { text-decoration: none; }
}

@layer states {
  .c[hidden] { display: none; }
  .load-more[hidden] { display: none; }

  @media (max-width: 900px) {
    .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .catalog-cta { align-items: flex-start; flex-direction: column; }
    footer { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    footer p { display: none; }
  }

  @media (max-width: 620px) {
    .header { padding-inline: 1rem; }
    .back-link span, .creator-link svg { display: none; }
    .back-link { padding-inline: 0.7rem; }
    .creator-link { font-size: 0.62rem; }
    .hero { min-height: 43rem; }
    .hero__content { padding-inline: 1.2rem; }
    .hero h1 { font-size: clamp(3.6rem, 19vw, 6.2rem); }
    .hero__meta { gap: 2rem; align-items: flex-start; flex-direction: column; }
    .catalog__inner { padding-inline: 1rem; }
    .catalog__intro { align-items: flex-start; flex-direction: column; }
    .catalog-tools { margin-inline: -1rem; padding-inline: 1rem; }
    .search { height: 3.65rem; }
    .search kbd { display: none; }
    .catalog-grid { grid-template-columns: 1fr; }
    .c { min-height: 12rem; }
    .card-name { font-size: 2rem; }
    .catalog-cta { padding-inline: 1.2rem; }
    .catalog-cta h2 { font-size: clamp(3.2rem, 16vw, 5rem); }
    footer { padding-inline: 1.2rem; }
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: 0.01ms !important; }
  }
}
