/* ==========================================================================
   Ankala shared styles: every page loads tokens.css, then this file.
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 4px; border-radius: 2px; }
::selection { background: var(--durazno); color: var(--cobalto); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 var(--gutter); }
.wrap.narrow { max-width: 820px; }
main { display: block; }
.section { padding: clamp(56px, 9vw, 112px) 0; }
.section + .section { padding-top: 0; }
.rule { border: 0; border-top: 1px solid var(--hairline); }

/* ---------- type helpers ---------- */
.over { font: 500 12px var(--font-mono); letter-spacing: var(--track-overline); text-transform: uppercase; color: var(--fg-muted); }
.mono { font-family: var(--font-mono); }
.caps { text-transform: uppercase; letter-spacing: var(--track-caps); }
.h1 { font-size: clamp(34px, 5.4vw, 76px); font-weight: 500; line-height: 1.02; letter-spacing: -.01em; }
.h2 { font-size: clamp(26px, 3.2vw, 44px); font-weight: 500; line-height: 1.08; letter-spacing: -.005em; }
.h3 { font-size: clamp(16px, 1.25vw, 19px); font-weight: 600; text-transform: uppercase; letter-spacing: var(--track-caps); }
.lede { font: 400 clamp(14px, 1.05vw, 17px)/1.65 var(--font-mono); color: var(--fg); max-width: 40em; }
.muted { color: var(--fg-muted); }
.tagline { font: 400 var(--text-tagline) var(--font-mono); letter-spacing: var(--track-tagline); text-transform: uppercase; }

/* ---------- header ---------- */
.site-header {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  padding: 34px 62px 0;
}
.site-header .brand { margin-right: auto; line-height: 0; }
.site-header .brand img { height: 26px; width: auto; }
.site-header.is-home .brand { visibility: hidden; }
.site-nav ul { display: flex; gap: clamp(28px, 3.8vw, 64px); list-style: none; }
.site-nav a { font-size: 18px; font-weight: 500; letter-spacing: .005em; position: relative; white-space: nowrap; }
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform var(--dur) var(--ease);
}
.site-nav a:hover::after, .site-nav a[aria-current="page"]::after { transform: scaleX(1); }
.head-tools { display: flex; align-items: center; gap: 10px; margin-left: clamp(16px, 3vw, 44px); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; position: relative; }
.icon-btn svg { width: 30px; height: 30px; }
.icon-btn .badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--mandarina); color: var(--vino); font: 600 11px/18px var(--font-sans); text-align: center;
}
.menu-btn { display: none; }
.nav-account { display: none; }

@media (max-width: 960px) {
  .site-header { padding: 18px 16px 0; gap: 0; }
  .menu-btn { display: grid; }
  .head-tools { gap: 0; }
  .site-nav { position: fixed; inset: 0; z-index: 40; background: var(--bg-deep);
    display: grid; place-items: center; opacity: 0; visibility: hidden; transition: opacity var(--dur), visibility var(--dur); }
  .site-nav.open { opacity: 1; visibility: visible; }
  .site-nav ul { flex-direction: column; align-items: center; gap: 30px; }
  .site-nav a { font-size: 28px; }
  .site-nav .nav-close { position: absolute; top: 18px; right: 16px; }
  .nav-account { display: list-item; }
}
@media (min-width: 961px) { .site-nav .nav-close { display: none; } }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--hairline); margin-top: clamp(64px, 10vw, 128px); padding: 56px 0 40px; }
.site-footer .cols { display: grid; gap: 40px; grid-template-columns: 1.4fr repeat(3, 1fr); }
.site-footer .logo img { height: 30px; width: auto; }
.site-footer h4 { font: 500 12px var(--font-mono); letter-spacing: var(--track-overline); text-transform: uppercase; color: var(--fg-muted); margin-bottom: 14px; }
.site-footer ul { list-style: none; display: grid; gap: 8px; }
.site-footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
.site-footer .news { margin-top: 22px; display: flex; gap: 10px; max-width: 360px; }
.site-footer .bottom { margin-top: 48px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; font: 12px var(--font-mono); color: var(--fg-muted); }
@media (max-width: 760px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } .site-footer .cols > :first-child { grid-column: 1 / -1; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 48px; padding: 0 24px; border-radius: var(--radius-pill);
  background: var(--durazno); color: var(--cobalto); font-weight: 600; font-size: 15px; letter-spacing: .01em;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast), color var(--dur-fast);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 var(--stroke) var(--line); }
.btn.ghost:hover { background: rgb(252 219 186 / .08); }
.btn.small { height: 38px; padding: 0 16px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.link-arrow { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; }
.link-arrow svg { width: 32px; height: 14px; transition: transform var(--dur) var(--ease); }
.link-arrow:hover svg { transform: translateX(5px); }

/* ---------- the + (save) button ---------- */
.plus {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 var(--stroke) currentColor;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur) var(--ease);
}
.plus svg { width: 18px; height: 18px; transition: transform var(--dur) var(--ease); }
.plus:hover { transform: scale(1.06); }
.plus[aria-pressed="true"] { background: var(--durazno); color: var(--cobalto); box-shadow: none; }
.plus[aria-pressed="true"] .ico-check { animation: tick .35s var(--ease); }
@keyframes tick { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }
.plus .ico-check { display: none; }
.plus[aria-pressed="true"] .ico-plus { display: none; }
.plus[aria-pressed="true"] .ico-check { display: block; }
.plus.pop { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.22); } }
.plus.on-light { color: var(--vino); }
.plus.on-light[aria-pressed="true"] { background: var(--vino); color: var(--durazno); }
.plus-label { display: inline-flex; align-items: center; gap: 12px; font-weight: 500; cursor: pointer; }
.dialog .close-link { font: 13px var(--font-mono); color: var(--fg-muted); text-decoration: underline; text-underline-offset: 3px; }
.dialog .close-link:hover { color: var(--fg); }

/* ---------- corner frame ---------- */
.frame { position: absolute; inset: 0; pointer-events: none; }
.frame i { position: absolute; width: 26px; height: 26px; border: var(--stroke) solid currentColor; }
.frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius-corner); }
.frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: var(--radius-corner); }
.frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: var(--radius-corner); }
.frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius-corner); }

/* ---------- tags / chips ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font: 12px var(--font-mono); letter-spacing: .06em; text-transform: lowercase;
  padding: 5px 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-pill);
  color: var(--fg-muted); transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
a.tag:hover, button.tag:hover { color: var(--fg); border-color: var(--fg); }
.tag.search::before { content: "⌕"; }
.tag.solid { background: var(--durazno); color: var(--cobalto); border-color: var(--durazno); }

/* ---------- colour tiles ---------- */
.t-cobalto { background: rgb(252 219 186 / .07); color: var(--durazno); box-shadow: inset 0 0 0 1px var(--hairline); }
.t-durazno { background: var(--durazno); color: var(--vino); }
.t-vino { background: var(--vino); color: var(--durazno); }
.t-olivo { background: var(--olivo); color: var(--durazno); }
.t-mandarina { background: var(--mandarina); color: var(--vino); }
.t-crema { background: var(--crema); color: var(--vino); }

/* ---------- brand card ---------- */
.cards { display: grid; gap: clamp(16px, 2vw, 28px) clamp(14px, 1.6vw, 24px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.card { position: relative; display: flex; flex-direction: column; gap: 14px; }
.card .tile { position: relative; aspect-ratio: 4 / 4.4; border-radius: 4px; overflow: hidden; display: grid; place-items: end center; padding: 14% 18% 12%; }
.card .tile img { width: auto; max-width: 78%; max-height: 82%; object-fit: contain; transition: transform .5s var(--ease); }
.card .tile .frame { inset: 16px; opacity: 0; transform: scale(1.04); transition: opacity var(--dur), transform var(--dur) var(--ease); }
.card:hover .tile img { transform: scale(1.05) translateY(-2%); }
.card:hover .tile .frame { opacity: .9; transform: none; }
.card .plus { position: absolute; top: 12px; right: 12px; z-index: 2; }
.card .meta { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card h3 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--track-caps); }
.card .sub { font: 13px/1.5 var(--font-mono); color: var(--fg-muted); }
.card .price { font: 13px var(--font-mono); color: var(--fg-muted); white-space: nowrap; }
.card .cover-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card .badge-new { position: absolute; left: 12px; top: 14px; z-index: 2; font: 500 11px var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }

/* ---------- forms ---------- */
.field { display: grid; gap: 8px; }
.field > span, .label { font: 500 12px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--fg-muted); }
.input, .select, .textarea {
  width: 100%; background: transparent; border: 0; border-bottom: var(--stroke) solid var(--line-soft);
  color: var(--fg); padding: 10px 2px; font-size: 17px; outline: none; border-radius: 0;
  transition: border-color var(--dur-fast);
}
.input:focus, .select:focus, .textarea:focus { border-bottom-color: var(--fg); }
.input::placeholder, .textarea::placeholder { color: var(--fg-muted); } /* 4.8:1 on cobalto */
.textarea { resize: vertical; min-height: 110px; line-height: 1.55; border: var(--stroke) solid var(--line-soft); padding: 12px 14px; border-radius: 4px; font-size: 15px; }
.textarea:focus { border-color: var(--fg); }
.select { appearance: none; cursor: pointer; padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%23FCDBBA' stroke-width='1.5'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; background-size: 12px; }
.select option { background: var(--cobalto); color: var(--durazno); }
.check { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 15px; user-select: none; }
.check input { appearance: none; width: 20px; height: 20px; border-radius: 4px; border: var(--stroke) solid var(--line-soft); display: grid; place-items: center; flex: none; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
.check input:checked { background: var(--durazno); border-color: var(--durazno); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--cobalto); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--cobalto); transform: none; }
.check .count { margin-left: auto; font: 12px var(--font-mono); color: var(--fg-muted); }
.hint { font: 12px/1.5 var(--font-mono); color: var(--fg-muted); }
.error { font: 13px/1.5 var(--font-mono); color: var(--mandarina); }

/* ---------- segmented / tabs ---------- */
.seg { display: inline-flex; padding: 4px; border-radius: var(--radius-pill); box-shadow: inset 0 0 0 1px var(--line-soft); }
.seg button { height: 36px; padding: 0 16px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 500; color: var(--fg-muted); transition: background var(--dur-fast), color var(--dur-fast); display: inline-flex; align-items: center; gap: 8px; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--durazno); color: var(--cobalto); }

/* ---------- toast ---------- */
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { pointer-events: auto; background: var(--durazno); color: var(--cobalto); border-radius: var(--radius-pill); padding: 12px 20px; font-weight: 500; font-size: 15px; display: flex; gap: 16px; align-items: center; box-shadow: 0 10px 30px rgb(0 20 60 / .35); animation: toast-in .35s var(--ease); max-width: 100%; }
.toast a { text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.toast.out { opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }

/* ---------- dialog ---------- */
.dialog-back { position: fixed; inset: 0; z-index: 80; background: rgb(0 30 80 / .7); display: grid; place-items: center; padding: 16px; opacity: 0; visibility: hidden; transition: opacity var(--dur), visibility var(--dur); }
.dialog-back.open { opacity: 1; visibility: visible; }
.dialog { position: relative; background: var(--bg-deep); border-radius: 6px; padding: 44px 36px 36px; width: min(460px, 100%); text-align: center; display: grid; gap: 18px; justify-items: center; transform: translateY(10px); transition: transform var(--dur) var(--ease); }
.dialog-back.open .dialog { transform: none; }
.dialog .close { position: absolute; top: 8px; right: 8px; }
.dialog .frame { inset: 14px; opacity: .6; }

/* ---------- quick search overlay ---------- */
.qsearch { position: fixed; inset: 0; z-index: 70; background: rgb(0 51 124 / .97); display: flex; flex-direction: column; align-items: center; padding: 110px 24px 40px; overflow-y: auto; opacity: 0; visibility: hidden; transition: opacity var(--dur), visibility var(--dur); }
.qsearch.open { opacity: 1; visibility: visible; }
.qsearch .close { position: absolute; top: 30px; right: 54px; }
.qsearch form { width: min(680px, 100%); text-align: center; }
.qsearch .input { text-align: center; font: 500 var(--text-display) var(--font-sans); margin-top: 18px; border-bottom-color: var(--line); }
.qsearch .tags { justify-content: center; margin-top: 22px; }
.qsearch .results { list-style: none; width: min(680px, 100%); margin-top: 30px; }
.qsearch .results a { display: flex; align-items: center; gap: 18px; padding: 12px 8px; border-bottom: 1px solid var(--hairline); }
.qsearch .results a:hover, .qsearch .results a:focus-visible { background: rgb(252 219 186 / .06); }
.qsearch .results img { width: 44px; height: 50px; object-fit: contain; }
.qsearch .results strong { display: block; font-weight: 600; text-transform: uppercase; font-size: 15px; letter-spacing: .02em; }
.qsearch .results span { font: 13px var(--font-mono); color: var(--fg-muted); }
.qsearch .all { margin-top: 26px; }
@media (max-width: 760px) { .qsearch .close { right: 16px; top: 18px; } .qsearch { padding-top: 80px; } }

/* ---------- page head ---------- */
.page-head { padding: clamp(48px, 8vw, 104px) 0 clamp(32px, 5vw, 56px); text-align: center; }
.page-head .over { display: block; margin-bottom: 18px; }
.page-head .lede { margin: 20px auto 0; }

/* ---------- photo placeholder ---------- */
.ph { position: relative; border-radius: 4px; overflow: hidden; display: grid; place-items: center; }
.ph img { width: 46%; max-height: 70%; object-fit: contain; }
.ph figcaption, .ph .ph-cap { position: absolute; left: 16px; bottom: 14px; right: 16px; font: 11px/1.4 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; opacity: .8; text-align: left; }
.ph .ph-tag { position: absolute; top: 14px; left: 16px; font: 10px var(--font-mono); letter-spacing: .16em; text-transform: uppercase; opacity: .78; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 760px) {
  .dialog { padding: 40px 22px 28px; }
}
@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 22px 12px; }
  .card .plus { width: 34px; height: 34px; top: 8px; right: 8px; }
  .card .plus svg { width: 15px; height: 15px; }
  .card h3 { font-size: 13px; }
  .card .sub { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

/* shown when the database can't be reached */
.load-error { position: sticky; top: 0; z-index: 90; padding: 12px var(--gutter); background: var(--vino); color: var(--durazno); font: 500 14px var(--font-sans); text-align: center; }

/* a brand without a photo yet: its initials, set large in the tile */
.mono-art { width: 100%; height: 100%; min-height: 1em; display: grid; place-items: center; container-type: size; align-self: stretch; justify-self: stretch; }
.mono-art b { font: 500 42cqmin/1 var(--font-sans); letter-spacing: -.04em; opacity: .9; }
.empty-note { padding: clamp(48px, 7vw, 96px) 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); margin-bottom: clamp(48px, 7vw, 96px); }

/* ---------- Loading screen ----------
   Until the brands have loaded, a cobalt screen covers the page and the A
   from the wordmark writes itself (assets/loader-a.svg). app.js adds .ready to
   <body> when everything is in, and the screen fades away. On a fast
   connection it's gone before the A starts, so nobody sees a flash.
   If the scripts never run, it gives up after 12 s and shows the page anyway. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 1000; pointer-events: none;
  background: var(--cobalto) url("../assets/loader-a.svg") center / clamp(56px, 7vw, 84px) auto no-repeat;
  transition: opacity .4s var(--ease), visibility 0s linear .4s;
  animation: loader-give-up 0s linear 12s forwards;
}
body.ready::before { opacity: 0; visibility: hidden; }
@keyframes loader-give-up { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  body::before { background-image: url("../assets/a-durazno.svg"); background-size: clamp(44px, 5vw, 60px) auto; }
}

/* ---------- Costa Rica maps (app.js landSVG) ----------
   .coast draws the outline (twice as wide, since the fills cover its inner half);
   .fills are solid so the lines between provinces disappear. */
.land { --land-fill: #144C9A; --land-stroke: var(--line-soft); --land-stroke-w: .8; }
.land .coast path { fill: none; stroke: var(--land-stroke); stroke-width: calc(var(--land-stroke-w) * 2); stroke-linejoin: round; }
.land .fills path { fill: var(--land-fill); stroke: var(--land-fill); stroke-width: .35; } /* a hairline of fill closes tiny gaps between provinces */
.land .lake { fill: var(--bg); stroke: var(--land-stroke); stroke-width: .6; }

/* example content (Historias / Hallazgos before the first real one) */
.sample-note { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; margin: 0 0 28px; padding: 14px 18px; border-radius: 6px; background: rgb(255 95 57 / .14); box-shadow: inset 0 0 0 1px rgb(255 95 57 / .5); font: 13px/1.5 var(--font-mono); color: var(--fg); }
.sample-note b { font: 600 11px var(--font-sans); letter-spacing: .14em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--mandarina); color: var(--cobalto); }

/* ---------- brand photos fill their box ----------
   A brand's own photo covers the whole tile, cropping a little at the edges if its shape differs
   (never stretched). Cut-outs and initials keep the padded look. !important because each page
   sizes images inside its tiles for cut-outs. */
:is(.tile, .thumb, .th, .b-visual, .ph, .prev):has(> img.fill) { position: relative; overflow: hidden; }
:is(.tile, .thumb, .th, .b-visual, .ph, .prev) > img.fill { position: absolute !important; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: cover !important; }
.card:hover .tile img.fill { transform: scale(1.04); }
:is(.tile, .thumb, .th, .b-visual, .ph, .prev):has(> img.fill) > .frame { display: none; }
/* labels sitting on a photo get a solid pill so they stay readable */
:is(.tile, .b-visual, .ph):has(> img.fill) > :is(.stamp, .ph-tag, .idx, figcaption, .badge-new) { z-index: 1; width: fit-content; background: var(--cobalto); color: var(--durazno); padding: 4px 9px; border-radius: 999px; opacity: 1; }
