/* ==== uwuapps theme (uwuapps-theme.md, section 1) ==== */

/* ---- base ---- */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Jua", "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

html, body { height: 100%; }
input, textarea { user-select: text; }

:link, :visited { color: var(--brand-ink); }
a:hover { text-decoration: none; }

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:disabled { cursor: not-allowed; opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- brand colour tokens (7 swatches) ---- */
:root,
:root[data-color-theme="classic"] {
  --brand: #ccffcc;
  --brand-rgb: 204, 255, 204;
}
:root[data-color-theme="not-green-1"] { --brand: #ffcccc; --brand-rgb: 255, 204, 204; }
:root[data-color-theme="not-green-2"] { --brand: #ccccff; --brand-rgb: 204, 204, 255; }
:root[data-color-theme="not-green-3"] { --brand: #ffffcc; --brand-rgb: 255, 255, 204; }
:root[data-color-theme="not-green-4"] { --brand: #ffccff; --brand-rgb: 255, 204, 255; }
:root[data-color-theme="not-green-5"] { --brand: #ccffff; --brand-rgb: 204, 255, 255; }
:root[data-color-theme="really-light-green"] { --brand: #ffffff; --brand-rgb: 255, 255, 255; }

/* ---- light / dark surface tokens ---- */
:root,
:root[data-mode="light"] {
  --bg: #eef2f0;
  --surface: rgba(255, 255, 255, 0.55);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(255, 255, 255, 0.65);
  --ink: #121815;
  --muted: #5b665f;
  --shadow: 0 10px 30px rgba(20, 40, 30, 0.10);
  --brand-ink: #1f6b3d;
  --ok: #0f7234;
  --warn: #a24b08;
  --busy: #627288;
  --error: #b91c1c;
}

:root[data-mode="dark"] {
  --bg: #0c100e;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.11);
  --surface-border: rgba(255, 255, 255, 0.14);
  --ink: #eef2ef;
  --muted: #9aa7a0;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --brand-ink: #bff5cf;
  --ok: #4ade80;
  --warn: #fbbf24;
  --busy: #94a3b8;
  --error: #fa9696;
}

/* Same in both modes: brand tints are pale whatever the mode. */
:root {
  --on-brand: #121815;
  /* Brand-derived fills. Any surface that tracked the brand swatch before
     still tracks it, in both modes. Text on these is always --on-brand. */
  --brand-fill: color-mix(in srgb, var(--brand) 55%, var(--surface-strong));
  --brand-fill-strong: color-mix(in srgb, var(--brand) 75%, var(--surface-strong));
  /* Secondary text on --surface-strong. Plain --muted only reaches 3.6:1
     there in dark mode, since the strong surface lightens the backdrop. */
  --muted-strong: color-mix(in srgb, var(--ink) 70%, transparent);
}

/* flat, static colour derived from theme, no gradients */
body {
  background-color: color-mix(in srgb, var(--brand) 10%, var(--bg));
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ---- glass primitive ---- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* ---- icon button (theme trigger, modal close) ---- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 16px; height: 16px; }

/* ---- modal shell ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 15, 12, 0.35);
  padding: 12px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}
.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0s linear 0.18s;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-strong);
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease;
}
.modal-backdrop.hidden .modal {
  opacity: 0;
  transform: translateY(14px) scale(0.97);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { font-size: 1.1rem; color: var(--brand-ink); }

/* Section labels inside the modal: "Mode", "Brand colour". */
.modal-section-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

body.modal-open { overflow: hidden; }

/* ---- mode toggle ---- */
.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
}
.mode-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn svg { width: 16px; height: 16px; }
.mode-btn.active {
  background: var(--brand-fill);
  color: var(--on-brand);
}

/* Time based mode only. Light and dark stay side by side and the third
   spans the row beneath them: two equal columns would put the longer label
   in a box too narrow to read at 320px, and the full width row also signals
   this is a different kind of choice, a rule for picking a mode rather than
   a mode. Omit both rules in an app that ships the two button toggle. */
.mode-btn-wide { grid-column: 1 / -1; }
.mode-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---- swatch grid ---- */
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  font-size: 0.78rem;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Ringed in its own colour, plus a containment ring. On a light modal the
   pale swatches reach only 1:1 against the surface on their own, so the
   outer ring is what actually carries the active state, at 3.4:1. */
.swatch.active {
  border-color: var(--swatch-color);
  box-shadow:
    0 0 0 2px var(--swatch-color),
    0 0 0 3px color-mix(in srgb, var(--ink) 50%, transparent);
}
.swatch-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--swatch-color);
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .swatch-grid { grid-template-columns: 1fr; }
}

/* ==== Cocktail Guide ==== */

::selection {
  background: var(--brand-fill-strong);
  color: var(--on-brand);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 2px;
}

/* ---- layout ---- */
.topbar,
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--brand-ink);
}

.container { padding-top: 0; }

.card { padding: 1.8em; }

/* ---- buttons ---- */
.btn {
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 999px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--brand-fill);
  color: var(--on-brand);
}
.btn-primary:hover { background: var(--brand-fill-strong); }

.btn-quiet {
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  color: var(--ink);
}

/* ---- search ---- */
.search-container {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 1.2em;
}

.search-container input {
  font-size: 1rem;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}
.search-container input::placeholder {
  color: var(--muted-strong);
  opacity: 1;
}
.search-container input:focus { border-color: var(--brand-ink); }

/* ---- result ---- */
#result { line-height: 1.7; }

#result img {
  display: block;
  width: 100%;
  max-width: 12.5em;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  object-fit: cover;
}

#result h2 {
  font-size: 1.25em;
  font-weight: 400;
  margin: 0.8em 0 1.6em 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  position: relative;
}

#result h2::before {
  content: "";
  position: absolute;
  width: 15%;
  height: 3px;
  border-radius: 3px;
  background-color: var(--brand-ink);
  left: 42.5%;
  bottom: -0.3em;
}

#result h3 {
  font-size: 1.1em;
  font-weight: 400;
  margin-bottom: 0.2em;
  color: var(--brand-ink);
}

#result ul {
  margin: 0 0 1em 1.8em;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.8em;
}

#result li { margin-bottom: 0.3em; }

#result p { font-size: 0.95em; }

#result .msg {
  font-size: 1.05em;
  font-weight: 400;
  text-align: center;
  color: var(--muted);
  margin: 0.6em 0;
}
#result .msg.error { color: var(--error); }

/* ---- update bar (update-bar-spec.md) ---- */
/* Mostly surface with a light brand tint, so --ink reads on it in both
   modes. --on-brand would drop to about 2.6:1 here in dark mode. Show and
   hide is a .hidden flip; the grid row collapse animates the height. */
.update-notice {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  background: color-mix(in srgb, var(--brand) 25%, var(--surface-strong));
  border-bottom: 1px solid var(--surface-border);
  color: var(--ink);
  font-size: 0.875rem;
  opacity: 1;
  visibility: visible;
  animation: update-notice-in 0.2s ease;
  transition: grid-template-rows 0.2s ease, opacity 0.18s ease, visibility 0s linear 0s;
}
.update-notice.hidden {
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  border-bottom-width: 0;
  transition: grid-template-rows 0.2s ease, opacity 0.18s ease, visibility 0s linear 0.2s;
}

@keyframes update-notice-in {
  from {
    grid-template-rows: 0fr;
    opacity: 0;
  }
}

.update-notice-inner {
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.5rem 14px;
  /* Under the notch on a phone, where the bar is the topmost thing on screen. */
  padding-top: max(0.5rem, env(safe-area-inset-top));
}

.update-notice p { flex: 1 1 12rem; min-width: 0; }
.update-notice .btn {
  flex: none;
  font-size: 0.875rem;
  padding: 6px 14px;
}

@media (max-width: 480px) {
  .topbar,
  .container,
  .update-notice-inner {
    padding-left: 10px;
    padding-right: 10px;
  }
  .container { padding-bottom: 10px; }
  .card { padding: 1.2em; }
  #result ul { grid-template-columns: 1fr; }
}
