/* Base styling only. The real visual work arrives with the flower SVGs. */

:root {
  --paper: #fdf8f4;
  --ink: #33272a;
  --muted: #7a6a6e;
  --accent: #c2405a;
  --accent-dark: #7d2338;
  --line: #e8dbd4;
  --danger: #9b2c3c;
  --danger-bg: #fbe9ec;
  --notice: #2f6b46;
  --notice-bg: #e8f3ec;
  --selected-bg: #fbeef1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1618;
    --ink: #f2e9e6;
    --muted: #b3a2a6;
    --accent: #e0687f;
    --accent-dark: #c2405a;
    --line: #382c30;
    --danger: #f0a3ae;
    --danger-bg: #3a1f25;
    --notice: #8fd0a8;
    --notice-bg: #1d2f24;
    --selected-bg: #2a1c20;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-serif, Georgia, "Iowan Old Style", serif;
  line-height: 1.55;
  /* Keeps content clear of the notch and the home indicator. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.card {
  width: min(24rem, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* The history needs more room than a single flower does. */
.card.wide {
  width: min(32rem, 100%);
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Anything more specific overrides this; it only keeps stray links out of the
   browser's default blue and visited-purple. */
a {
  color: var(--accent);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: transparent;
  color: inherit;
  /* Below 16px iOS Safari zooms the page on focus. */
  font: inherit;
  font-size: 1rem;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

button {
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.6rem;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.quiet {
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0;
  text-decoration: underline;
}

button.quiet:hover {
  color: var(--ink);
}

.error {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.6rem;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.95rem;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* The pair code is read aloud or typed by hand, so it gets room to breathe and
   a monospace face where 5 and S cannot be mistaken for one another. */
.code {
  margin: 0;
  padding: 0.9rem 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.25em;
  /* Balances the trailing letter-space so the code still looks centred. */
  text-indent: 0.25em;
  text-align: center;
  user-select: all;
}

.quiet-link {
  color: var(--muted);
  font-size: 0.95rem;
}

.quiet-link:hover {
  color: var(--ink);
}

/* The flower on its own page, as large as the card allows. */
.bloom {
  width: 100%;
  max-width: 13rem;
  height: auto;
  align-self: center;
}

.message {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.45;
  /* Keeps a pasted line of 200 characters from pushing the page sideways. */
  overflow-wrap: anywhere;
  white-space: pre-line;
}

/* A link that carries the weight of the main action, without being a form. */
.button-link {
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-dark);
}

/* The history: filter row, then one line per flower. */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.filter-active {
  border-color: var(--accent);
  background: var(--selected-bg);
  color: var(--ink);
}

.entries {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  color: inherit;
  text-decoration: none;
}

.entry:hover {
  border-color: var(--accent);
  background: var(--selected-bg);
}

.entry img {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 3rem;
}

.entry-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  /* Without this a long message stretches the row instead of being truncated. */
  min-width: 0;
}

.entry-message {
  overflow-wrap: anywhere;
}

.notice {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 0.6rem;
  background: var(--notice-bg);
  color: var(--notice);
  font-size: 0.95rem;
}

/* The flower picker. The fieldset stays a plain block and the grid sits in a
   child, because a fieldset as a grid container is still shaky in Safari. */
.flowers {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.flowers legend {
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.flower-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.flower {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  text-align: center;
  cursor: pointer;
}

.flower input {
  /* Out of sight but still focusable, so the choice stays reachable by keyboard
     and is announced as a radio group. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
}

.flower img {
  width: 100%;
  max-width: 4.5rem;
  height: auto;
}

.flower span {
  font-size: 0.8rem;
  color: var(--muted);
}

.flower:has(input:checked) {
  border-color: var(--accent);
  background: var(--selected-bg);
}

.flower:has(input:checked) span {
  color: var(--ink);
}

.flower:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
