/*
 * Look = font set × theme × brightness, chosen in Settings and set on <html>
 * as data-font, data-theme, data-brightness (accounts/context_processors.py).
 * Colors use light-dark(): "auto" follows the device, light/dark force one.
 * The font set's @font-face rules come from static/fonts/<set>.css.
 */

:root {
  color-scheme: light dark;

  /* Theme "paper" (default). Keep in sync with share/card.py colors. */
  --bg: light-dark(#f8f5ef, #1a1815);
  --fg: light-dark(#24211c, #ece6dc);
  --muted: light-dark(#6f685d, #a59d90);
  --line: light-dark(#e3ddd2, #36322c);
  --accent: light-dark(#2c4a6e, #9bb6d6);
  --on-accent: light-dark(#ffffff, #1a1815);
  --danger: light-dark(#b3261e, #f2b8b5);
  --on-danger: light-dark(#ffffff, #1a1815);

  /* Font set "book" (default). --quote: what people saved; --ui: everything around it. */
  --quote: "Source Serif 4", "Noto Serif KR", Georgia, serif;
  --ui: "IBM Plex Sans", "IBM Plex Sans KR", system-ui, sans-serif;
}

:root[data-brightness="light"] {
  color-scheme: light;
}

:root[data-brightness="dark"] {
  color-scheme: dark;
}

:root[data-theme="ink"] {
  --bg: light-dark(#ffffff, #0f1115);
  --fg: light-dark(#14171c, #e8eaee);
  --muted: light-dark(#5d6470, #9aa1ad);
  --line: light-dark(#e5e7eb, #262a33);
  --accent: light-dark(#1d4ed8, #7aa2ff);
  --on-accent: light-dark(#ffffff, #0f1115);
  --on-danger: light-dark(#ffffff, #0f1115);
}

:root[data-theme="sage"] {
  --bg: light-dark(#f4f6f2, #141a17);
  --fg: light-dark(#1d2420, #e3e9e4);
  --muted: light-dark(#5f6b63, #98a59d);
  --line: light-dark(#dce2db, #2b352f);
  --accent: light-dark(#2f6b4f, #8cc7a8);
  --on-accent: light-dark(#ffffff, #141a17);
  --on-danger: light-dark(#ffffff, #141a17);
}

:root[data-font="editorial"] {
  --quote: "Newsreader", "Nanum Myeongjo", Georgia, serif;
  --ui: "Instrument Sans", "Noto Sans KR", system-ui, sans-serif;
}

:root[data-font="reading"] {
  --quote: "Literata", "Noto Serif KR", Georgia, serif;
  --ui: var(--quote);
}

:root[data-font="modern"] {
  --quote: "Inter", "Noto Sans KR", system-ui, sans-serif;
  --ui: var(--quote);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0 auto;
  max-width: 42rem;
  padding: 0 1.25rem;
  color: var(--fg);
  background: var(--bg);
  font: 1rem/1.6 var(--ui);
}

/* Long unbroken input (URLs) wraps instead of widening the page. */
[dir="auto"] {
  overflow-wrap: anywhere;
}

a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2 {
  font-family: var(--quote);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  margin: 1.75rem 0 1rem;
  font-size: 1.6rem;
  line-height: 1.25;
}

h2 {
  font-size: 1.2rem;
  line-height: 1.3;
}

/* ---- Layout ---- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  font: 600 1.2rem/1 var(--quote);
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  align-items: baseline;
  font-size: 0.875rem;
  color: var(--muted);
}

.site-nav a {
  text-decoration: none;
}

.site-nav a:hover,
.site-nav button.link:hover {
  color: var(--fg);
}

.site-nav button.link {
  color: inherit;
  text-decoration: none;
}

.site-footer {
  display: flex;
  gap: 1rem;
  margin-top: 4rem;
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

.messages {
  margin: 1rem 0 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  list-style: none;
  font-size: 0.9rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
}

.page-head h1 {
  margin-bottom: 1.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
  align-items: center;
  font-size: 0.9rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 20rem;
}

.stack > button {
  align-self: flex-start;
}

.stack.wide {
  max-width: none;
  gap: 1.25rem;
}

form.inline {
  display: inline;
}

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

/* ---- Controls ---- */

button,
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font: 500 0.9rem/1.2 var(--ui);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  filter: brightness(1.1);
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
}

button.more {
  display: block;
  margin: 1.5rem auto;
  border-color: var(--line);
  background: transparent;
  color: inherit;
}

button.destructive {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--on-danger);
}

input[type="text"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: 0.95rem/1.4 var(--ui);
}

select {
  width: auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

textarea {
  font: 1.05rem/1.6 var(--quote);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

.field label,
.field legend {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.field fieldset,
fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

.field fieldset div,
.choices > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

.field fieldset label,
.choices label {
  display: inline;
  font-weight: 400;
}

.field small {
  color: var(--muted);
  font-size: 0.8rem;
}

.errorlist {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 0.85rem;
}

.danger {
  margin-top: 2rem;
  color: var(--danger);
}

/* ---- Quotes ---- */

.quote {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}

.quote blockquote {
  margin: 0;
  font: 1.2rem/1.6 var(--quote);
}

.attribution {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.attribution cite {
  color: var(--fg);
}

/* Korean and other scripts have no italic; slanting them by force looks broken. */
cite {
  font-synthesis-style: none;
}

.attribution a {
  text-decoration: none;
}

.attribution a:hover {
  text-decoration: underline;
}

.note {
  margin: 0.75rem 0 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  align-items: center;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.meta a {
  text-decoration: none;
}

.meta a:hover {
  color: var(--fg);
}

.badge {
  padding: 0.05rem 0.5rem;
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  align-items: baseline;
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
}

.chip {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

.chip:hover {
  border-color: var(--muted);
  color: var(--fg);
}

.save.saved {
  text-decoration: none;
}

#random-card > button {
  margin-top: 1rem;
}

/* ---- Pages ---- */

.hero {
  padding: 2.5rem 0 1.5rem;
}

.hero h1 {
  margin-top: 0;
  font-size: 2.1rem;
  line-height: 1.2;
}

.hero p {
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.filter-options button {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

/* Sits right under the quote, whose bottom rule separates the two. */
.share {
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

.share-link {
  display: flex;
  gap: 0.5rem;
}

.share-link input {
  min-width: 0;
}

.share-link button {
  white-space: nowrap;
}

.share button.link {
  color: var(--muted);
  font-size: 0.8rem;
}

.browse ul {
  padding: 0;
  list-style: none;
}

.browse li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.browse li a {
  text-decoration: none;
}

.legal {
  max-width: 38rem;
}

.legal h2 {
  margin-top: 2rem;
  font-size: 1.15rem;
}

.danger-zone {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
