/**
 * Building blocks used across the site: navbar, buttons, inputs, toast.
 */

/* ============ Navbar ============ */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: var(--s-24);
  padding: 0 var(--s-24);
  background: var(--nav-bg);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
}
/* marketing pages: content width, see-through until the page scrolls */
.nav--site { padding: 0 max(var(--gutter), calc((100vw - var(--container)) / 2)); }
.nav--clear:not([data-scrolled]):not([data-menu]) {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Icon Stack lockup: the orange symbol (a tile cut into three stacked slabs) and the wordmark */
.brand {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand__mark { display: block; width: 24px; height: 24px; fill: var(--brand); }
.brand__word {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

/* main links, centered */
.nav__links {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav__hover {
  position: absolute;
  top: 0; left: 0;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), width 0.35s var(--ease-out), opacity 0.2s;
}
.nav__link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 450;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav__link:hover, .nav__link[aria-current='page'] { color: var(--ink); }
.nav__link[aria-current='page']::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -16px;
  height: 1.5px;
  background: var(--ink);
}

.nav__end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav__login, .nav__signup { min-width: 72px; }
.nav__login { border-color: transparent; background: none; }
.nav__login:hover { border-color: var(--line); }

.nav__menu {
  display: none;
  width: 32px; height: 32px;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.nav__menu span {
  grid-area: 1 / 1;
  width: 14px; height: 1.5px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform 0.4s var(--ease-out);
}
.nav__menu span:first-child { transform: translateY(-3px); }
.nav__menu span:last-child { transform: translateY(3px); }
.nav__menu[aria-expanded='true'] span:first-child { transform: rotate(45deg); }
.nav__menu[aria-expanded='true'] span:last-child { transform: rotate(-45deg); }

.nav__sheet {
  position: fixed;
  top: var(--nav-h); left: 0; right: 0; bottom: 0;
  z-index: 39;
  padding: var(--s-16) var(--gutter) var(--s-32);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: sheetIn 0.35s var(--ease-out);
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(-8px); } }
.nav__sheet a:not(.btn) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  animation: fadeUp 0.45s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.nav__sheet a:not(.btn)::after { content: '→'; color: var(--faint); font-size: 16px; }
.nav__sheet .btn { margin-top: var(--s-24); height: 48px; font-size: var(--fs-body); }
.nav__sheet .sheet__auth { display: grid; gap: var(--s-8); margin-top: var(--s-24); }
.nav__sheet .sheet__auth .btn { margin-top: 0; }

/* search (gallery toolbar) */
.search {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 624px;
  height: 40px;
  display: flex;
  align-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  cursor: text;
  transition: border-color 0.25s, box-shadow 0.35s var(--ease-out);
}
.search:hover { border-color: var(--line-strong); }
.search:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
}
.search__icon {
  width: 20px; height: 20px;
  margin-left: 12px;
  color: var(--muted);
  flex-shrink: 0;
  transition: color 0.25s, transform 0.45s var(--ease-spring);
}
.search:focus-within .search__icon { color: var(--ink); transform: rotate(-12deg) scale(1.08); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-body);
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search__kbd {
  margin-right: 8px;
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  transition: opacity 0.2s, transform 0.3s var(--ease-out);
}
.search:focus-within .search__kbd,
.search.has-value .search__kbd { opacity: 0; transform: scale(0.7); pointer-events: none; position: absolute; right: 0; }
.search__clear {
  width: 24px; height: 24px;
  margin-right: 8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.4s var(--ease-spring), background 0.2s, color 0.2s;
}
.search__clear svg { width: 16px; height: 16px; }
.search.has-value .search__clear { opacity: 1; transform: none; pointer-events: auto; }
.search__clear:hover { background: var(--surface-2); color: var(--ink); }

.nav__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

/* theme switch */
.theme {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  transition: transform 0.3s var(--ease-spring), color 0.2s, background 0.2s;
}
.theme:hover { color: var(--ink); background: var(--accent-soft); transform: rotate(-8deg); }
.theme:active { transform: scale(0.9); }
.theme svg { width: 20px; height: 20px; overflow: visible; }
.theme__core { transition: r 0.55s var(--ease-out); }
.theme__bite { transition: cx 0.55s var(--ease-out), cy 0.55s var(--ease-out); }
.theme__rays { transform-origin: 12px 12px; transition: transform 0.6s var(--ease-out), opacity 0.35s; }
[data-theme='dark'] .theme__core { r: 7.5; }
[data-theme='dark'] .theme__bite { cx: 17; cy: 7; }
[data-theme='dark'] .theme__rays { transform: rotate(90deg) scale(0.4); opacity: 0; }

.nav__filters {
  display: none;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 500;
  flex-shrink: 0;
}
.nav__filters svg { width: 20px; height: 20px; }

/* ============ Navbar on small screens ============ */
@media (max-width: 860px) {
  .nav { gap: var(--s-8); padding: 0 var(--s-16); }
  .nav--site { padding: 0 var(--s-16); }
  .nav__links { display: none; }
  .nav__menu { display: grid; }
  .nav__filters { display: inline-flex; }
  .search__kbd { display: none; }
}
@media (max-width: 520px) {
  .nav__filters span { display: none; }
  .nav__filters { padding: 0 12px; }
}
@media (max-width: 480px) {
  .brand { gap: var(--s-8); }
  .brand__word { font-size: 18px; }
}
@media (max-width: 370px) {
  .nav__end .nav__login { display: none; } /* still in the menu */
}
@media (max-width: 340px) {
  .brand__word { display: none; }
}
/* ============ Segmented control ============ */
.segment {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segment__thumb {
  position: absolute;
  top: 4px; bottom: 4px; left: 0;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
  transition: transform 0.5s var(--ease-out), width 0.5s var(--ease-out);
}
.seg {
  position: relative;
  z-index: 1;
  height: 32px;
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  transition: color 0.25s;
}
.seg:hover, .seg[aria-checked='true'] { color: var(--ink); }
.seg small { font-family: var(--font-mono); font-size: 11px; opacity: 0.7; margin-left: 4px; }

/* ============ Buttons & inputs ============ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 var(--s-16);
  border-radius: 10px;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.3s var(--ease-spring), background 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.3s, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn--primary { color: var(--on-accent); background: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 20px -12px var(--accent-glow); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 24px -12px var(--accent-glow); }
.btn--lg { height: 48px; padding: 0 var(--s-24); font-size: var(--fs-body); border-radius: 12px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn--primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--ghost { color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.btn--ghost:hover { color: var(--ink); border-color: var(--line-strong); }
/* destructive actions (cancel, delete): red, so they're never mistaken for the main action */
.btn--danger { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.btn--danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.btn--danger-solid, .btn--danger-solid:hover { color: #fff; border-color: transparent; background: var(--danger); }
:root[data-theme='dark'] .btn--danger-solid { color: #1a0505; }
.btn--danger-solid:hover { box-shadow: 0 10px 22px -12px var(--danger); transform: translateY(-1px); }
.btn--danger:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--sm { height: 32px; padding: 0 var(--s-12); font-size: var(--fs-xs); border-radius: 8px; }
.btn--block { width: 100%; }

.btn__spinner {
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.3s var(--ease-spring);
}
.btn__label { transition: opacity 0.2s, transform 0.3s var(--ease-out); }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn__spinner { opacity: 1; transform: none; animation: spin 0.7s linear infinite; }
.btn.is-loading .btn__label { opacity: 0; transform: translateY(6px); }

.input-label { display: block; margin: 0 0 var(--s-8); font-size: var(--fs-xs); font-weight: 600; }
.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  outline: 0;
  transition: border-color 0.2s, box-shadow 0.3s var(--ease-out);
}
.input::placeholder { color: var(--muted); opacity: 0.8; }
.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--line-strong); box-shadow: 0 0 0 4px var(--accent-soft); }
.input[aria-invalid='true'] { border-color: #e5484d; box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.12); }
/* helper text under a form field */
.field__note { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8da8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.input.code {
  height: 180px;
  padding: 12px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  margin: 0 1px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-32);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--s-12);
  padding: var(--s-8) var(--s-16) var(--s-8) var(--s-8);
  border-radius: 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 140%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.55s var(--ease-spring), opacity 0.3s;
}
.toast.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
.toast.bump { animation: bump 0.4s var(--ease-spring); }
@keyframes bump { 50% { transform: translate(-50%, 0) scale(1.05); } }
.toast__icon {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.toast__icon svg { width: 16px; height: 16px; }
.toast__icon path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.toast.show .toast__icon path { animation: draw 0.5s 0.15s var(--ease-out) forwards; }
.toast__meta { opacity: 0.6; font-size: 12px; }
.toast__text code { font-family: var(--font-mono); font-size: 13px; }
.toast__text code { color: inherit; opacity: 0.7; }

/* ============ Sign in with Google ============ */
.btn--provider {
  height: 48px;
  gap: var(--s-12);
  padding: 0 var(--s-24);
  border-radius: 12px;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn--provider:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn--provider svg { width: 18px; height: 18px; }

/* ============ Account menu (signed in) ============ */
.account { position: relative; }
.account__btn {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.2s;
}
.account__btn:hover, .account__btn[aria-expanded='true'] { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--line-strong); }
.account__btn img { width: 100%; height: 100%; object-fit: cover; }
.account__menu {
  position: absolute;
  top: calc(100% + var(--s-8));
  right: 0;
  z-index: 50;
  width: 264px;
  padding: var(--s-8);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: menuIn 0.25s var(--ease-out);
  transform-origin: top right;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.account__who { display: grid; gap: 2px; padding: var(--s-8) var(--s-8) var(--s-12); border-bottom: 1px solid var(--line); margin-bottom: var(--s-8); }
.account__who b { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__who span { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__plan {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  width: max-content;
  margin-top: var(--s-8);
  padding: 2px var(--s-8);
  border-radius: 999px;
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.account__item {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  width: 100%;
  height: 36px;
  padding: 0 var(--s-8);
  border-radius: 8px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  text-decoration: none;
  text-align: left;
}
.account__item:hover, .account__item:focus-visible { background: var(--surface-2); color: var(--ink); }
.account__item--accent { color: var(--accent); font-weight: 500; }
.account__item svg { flex: none; width: 16px; height: 16px; color: var(--muted); transition: color 0.2s; }
.account__item:hover svg, .account__item:focus-visible svg, .account__item--accent svg { color: currentColor; }
.account__item[aria-current='page'] { background: var(--surface-2); color: var(--ink); }
.account__sep { height: 1px; margin: var(--s-8) 0; border: 0; background: var(--line); }

.nav__sheet .sheet__who { margin-top: var(--s-24); display: grid; gap: 2px; font-size: var(--fs-sm); color: var(--muted); }
.nav__sheet .sheet__who b { color: var(--ink); font-size: var(--fs-body); font-weight: 600; }
.nav__sheet .sheet__who + .sheet__auth { margin-top: var(--s-16); }

/* ============ Gate: today's free copies are used up, or a Pro style ============ */
.gate {
  width: min(440px, calc(100vw - var(--s-32)));
  max-width: none;
  margin: auto;
  padding: var(--s-40) var(--s-32) var(--s-32);
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg), 0 48px 96px -32px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.gate[open] { animation: gateIn 0.35s var(--ease-out); }
.gate.is-closing { animation: gateOut 0.18s var(--ease-out) forwards; }
@keyframes gateIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes gateOut { to { opacity: 0; transform: translateY(8px) scale(0.98); } }
.gate::backdrop {
  background: color-mix(in srgb, var(--bg) 55%, rgba(0, 0, 0, 0.35));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.gate__close {
  position: absolute;
  top: var(--s-12); right: var(--s-12);
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
}
.gate__close:hover { color: var(--ink); background: var(--surface-2); }
.gate__close svg { width: 16px; height: 16px; }
.gate__icon {
  width: 48px; height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  color: var(--accent);
  background: var(--accent-soft);
}
.gate__icon svg { width: 24px; height: 24px; }
.gate__title { margin: var(--s-16) 0 0; font-size: var(--fs-h3); line-height: 32px; letter-spacing: -0.02em; font-weight: 600; text-wrap: balance; }
.gate__text { margin: var(--s-8) 0 0; color: var(--muted); text-wrap: pretty; }
.gate__actions { display: grid; gap: var(--s-8); margin-top: var(--s-24); }
.gate__fine { margin: var(--s-16) 0 0; font-size: var(--fs-xs); color: var(--muted); }
.gate__fine a { color: var(--ink-2); }
@media (max-width: 600px) {
  .gate { padding: var(--s-32) var(--s-24) var(--s-24); }
}
