/* ─────────────────────────────────────────────
   Tokens
   ───────────────────────────────────────────── */
:root {
  /* Neutral palette — warm stone */
  --ink-900:   #18160f;
  --ink-700:   #38342a;
  --ink-500:   #6b6558;
  --ink-300:   #aea89e;
  --ink-100:   #e4e0d8;
  --ink-050:   #f2efea;

  /* Background */
  --bg:        #faf8f4;
  --bg-card:   #ffffff;

  /* ── Status palette ──────────────────────────
     All three share the same warmth register and
     saturation ceiling so they read as a family.

     Vegan   → sage green  (muted, botanical)
     Maybe   → ochre amber (warm, earthy)
     Not     → brick rose  (dusty, not alarm-red)
  */
  --vegan-bg:       #eaf2eb;
  --vegan-border:   #7aaa7e;
  --vegan-text:     #2a5c30;
  --vegan-dot:      #5a9960;

  --maybe-bg:       #f7f0e2;
  --maybe-border:   #c89c4a;
  --maybe-text:     #5a3d0a;
  --maybe-dot:      #b8862e;

  --notvegan-bg:    #f5ecea;
  --notvegan-border:#b8706a;
  --notvegan-text:  #5c1f1a;
  --notvegan-dot:   #a8524a;

  /* Type */
  --font-sans:  -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono:  "SF Mono", "Fira Mono", "Cascadia Code", monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ─────────────────────────────────────────────
   Reset & base
   ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink-700);
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 1.25rem 4rem;
  line-height: 1.5;
}

/* ─────────────────────────────────────────────
   App shell
   ───────────────────────────────────────────── */
.app {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 2.75rem;
}

/* ─────────────────────────────────────────────
   Header — centred
   ───────────────────────────────────────────── */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-align: center;
}

.app-title-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.app-icon {
  flex-shrink: 0;
  display: block;
}

.app-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink-900);
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--ink-300);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────
   Search form
   ───────────────────────────────────────────── */
.app-main {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--ink-100);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-wrap:focus-within {
  border-color: var(--vegan-border);
  box-shadow: 0 0 0 3px rgba(90, 153, 96, 0.12);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-900);
  padding: 0.75rem 0 0.75rem 1rem;
  text-transform: uppercase;
}

.search-input::placeholder {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-300);
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-300);
  transition: color 0.15s ease;
}

.search-btn:hover  { color: var(--ink-700); }
.search-btn:active { transform: scale(0.92); }

.input-hint {
  font-size: 0.8125rem;
  color: var(--ink-500);
  padding-left: 0.25rem;
  min-height: 1.2em;
}

.input-hint.error { color: var(--notvegan-dot); }

/* ─────────────────────────────────────────────
   Data attribution block
   ───────────────────────────────────────────── */
.data-attribution {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--ink-500);
  line-height: 1.6;
  letter-spacing: 0.01em;
  margin-top: -0.5rem;
}

/* Hairline rule with centred label */
.attr-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.attr-rule::before,
.attr-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ink-100);
}

.attr-rule-label {
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-300);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Two-column grid */
.attr-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 0 1.5rem;
  align-items: start;
  margin-top: 0.75rem;
}

/* Swap column order: key left, sources right */
.attr-col-key     { order: 1; }
.attr-col-sources { order: 2; }

/* Left-align column contents */
.attr-col {
  text-align: left;
}

.attr-col-heading {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--ink-300);
  margin-bottom: 0.45rem;
}

/* Sources column */
.attr-source-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
}

.attr-source-list li {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.attr-link-icon {
  flex-shrink: 0;
  color: var(--ink-300);
  position: relative;
  top: 0.05em;
}

.attr-source-list a {
  color: var(--ink-500);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--ink-100);
  transition: color 0.12s ease, text-decoration-color 0.12s ease;
}

.attr-source-list a:hover {
  color: var(--ink-700);
  text-decoration-color: var(--ink-300);
}

/* Vegan key column */
/*
  Two-column alignment: column 1 = label (sized to widest across all three
  rows), column 2 = description (all start at the same x position).

  The grid lives on .attr-key-list so a single max-content measurement spans
  all rows. .attr-key-row uses display:contents so its <dt> and <dd> children
  participate directly in the parent grid rather than forming isolated grids.
*/
.attr-key-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  row-gap: 0.35rem;
  column-gap: 0.4rem;
}

.attr-key-row {
  display: contents;
}

.attr-key-row dt {
  display: flex;
  align-items: baseline;
  align-self: baseline;
  gap: 0.3rem;
  white-space: nowrap;
}

.attr-key-row dd {
  align-self: baseline;
  color: var(--ink-300);
  font-size: 0.6875rem;
  line-height: 1.5;
}

/* Status dots — mirror the result-card badge dots */
.attr-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  top: -0.05em;
}

.attr-dot-vegan    { background: var(--vegan-dot); }
.attr-dot-maybe    { background: var(--maybe-dot); }
.attr-dot-notvegan { background: var(--notvegan-dot); }

.attr-status {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.attr-vegan    { color: var(--vegan-text); }
.attr-maybe    { color: var(--maybe-text); }
.attr-notvegan { color: var(--notvegan-text); }

/* Meta line */
.attr-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--ink-300);
  letter-spacing: 0.02em;
  margin-top: 0.75rem;
}

.attr-meta-sep {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-100);
  flex-shrink: 0;
}

.attr-meta-count,
.attr-meta-date {
  color: var(--ink-300);
}

/* ─────────────────────────────────────────────
   Result card
   ───────────────────────────────────────────── */
.result-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-card {
  background: var(--bg-card);
  border: 1.5px solid var(--ink-100);
  border-radius: 12px;
  padding: 1.25rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeUp 0.22s var(--ease-out) both;
}

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

/* Code + name */
.result-identity {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.result-code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-300);
  text-transform: uppercase;
}

.result-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0em;
  color: var(--ink-900);
  line-height: 1.3;
}

/* Functional class pill */
.result-class {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: fit-content;
}

.class-pill {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
  color: var(--ink-500);
  background: var(--ink-050);
  border: 1px solid var(--ink-100);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

/* Divider */
.result-divider {
  height: 1px;
  background: var(--ink-100);
  border: none;
  margin: 0 -0.25rem;
}

/* Vegan status badge */
.vegan-badge {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: 8px;
  padding: 0.75rem 0.875rem;
}

.vegan-badge.vegan {
  background: var(--vegan-bg);
  border: 1px solid var(--vegan-border);
}
.vegan-badge.maybe {
  background: var(--maybe-bg);
  border: 1px solid var(--maybe-border);
}
.vegan-badge.not-vegan {
  background: var(--notvegan-bg);
  border: 1px solid var(--notvegan-border);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.38em;
}

.vegan     .badge-dot { background: var(--vegan-dot); }
.maybe     .badge-dot { background: var(--maybe-dot); }
.not-vegan .badge-dot { background: var(--notvegan-dot); }

.badge-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.badge-label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
}

.vegan     .badge-label { color: var(--vegan-text); }
.maybe     .badge-label { color: var(--maybe-text); }
.not-vegan .badge-label { color: var(--notvegan-text); }

.badge-reason {
  font-size: 0.8125rem;
  line-height: 1.5;
}

.vegan     .badge-reason { color: var(--vegan-text); opacity: 0.8; }
.maybe     .badge-reason { color: var(--maybe-text); opacity: 0.8; }
.not-vegan .badge-reason { color: var(--notvegan-text); opacity: 0.8; }

/* ─────────────────────────────────────────────
   Not-found state
   ───────────────────────────────────────────── */
.not-found {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1.5px solid var(--ink-100);
  border-radius: 12px;
  animation: fadeUp 0.22s var(--ease-out) both;
}

.not-found-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink-700);
}

.not-found-sub {
  font-size: 0.8125rem;
  color: var(--ink-500);
  line-height: 1.5;
}

/* ─────────────────────────────────────────────
   Loading skeleton pulse
   ───────────────────────────────────────────── */
.skeleton {
  background: var(--bg-card);
  border: 1.5px solid var(--ink-100);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.skel-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-050) 50%, var(--ink-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skel-line.wide  { width: 65%; }
.skel-line.full  { width: 90%; }
.skel-line.short { width: 40%; height: 10px; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────
   Responsive tweaks
   ───────────────────────────────────────────── */
@media (max-width: 360px) {
  .search-input { font-size: 1.15rem; }
  .result-name  { font-size: 1.05rem; }
}
