/*
  Spirit of Diwata team tools: the look of spiritofdiwata.com.

  Shared by the dialogue editor (index.html), the text table (table.html) and the
  welcome tour (onboarding.js). The palette and type are the site's own
  (yg-homepage sites/spiritofdiwata/styles/sod.css): dark forest for the frame, journal
  paper and ink for the words being worked on, amber for the action that matters.

  Written for translators, not developers: generous type, plain labels, nothing that
  needs a hover to be understood.
*/

:root {
  --night: #10231e;
  --forest: #16302b;
  --moss: #2e5a4a;
  --paper: #f4e9d2;
  --paper-edge: #dcc79f;
  --print: #fbf6ea;
  --field: #fffaf0;
  --ink: #3a2410;
  --ink-soft: #62462a;
  --amber: #f5a623;
  --amber-deep: #d9731a;
  --amber-ink: #9b4a0c;
  --bark: #4a2c12;
  --gold: #f3d88a;
  --cream: #fdf6e6;
  --cream-soft: #e6dcc6;
  --sage: #9ccfa8;
  --terracotta: #d98c74;
  --rust: #9b3a22;
  --line-dark: rgba(253, 246, 230, 0.14);
  --display: Taviraj, "Shippori Mincho B1", Georgia, serif;
  --body: Nunito, "Zen Maru Gothic", Mali, system-ui, sans-serif;
  --tap: 2.5rem;

  /* Kept for the scripts, which colour a few messages through these names. */
  --red: var(--terracotta);
  --amber-text: var(--gold);
  --dim: var(--cream-soft);
  --accent: var(--gold);
  color-scheme: dark;
}

* { box-sizing: border-box; scrollbar-color: var(--moss) transparent; scrollbar-width: thin; }

body {
  margin: 0;
  background: var(--night);
  color: var(--cream);
  font: 15px/1.5 var(--body);
}

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

/* Japanese and Thai get faces drawn for them, at the same size as the Latin. */
:lang(ja), [data-lang="ja"] { font-family: "Zen Maru Gothic", Nunito, sans-serif; }
:lang(th), [data-lang="th"] { font-family: Mali, Nunito, sans-serif; }

/* ---------- the frame ---------- */

header, .bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.8rem;
  padding: 0.6rem 1rem;
  background: var(--forest);
  border-bottom: 1px solid var(--line-dark);
}

header h1 {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin: 0 0.6rem 0 0;
  font: 700 1.35rem/1.1 var(--display);
  color: var(--cream);
  white-space: nowrap;
}

header h1 .h1sub {
  font: 600 0.85rem var(--body);
  color: var(--cream-soft);
}

.hint { color: var(--cream-soft); font-size: 0.85rem; }

a { color: var(--gold); font-weight: 700; text-underline-offset: 3px; }

code {
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: rgba(253, 246, 230, 0.1);
  font: 0.85em ui-monospace, monospace;
}

/* ---------- buttons: the site's pills ---------- */

button {
  min-height: var(--tap);
  padding: 0.3rem 1rem;
  border: 2px solid rgba(253, 246, 230, 0.4);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font: 700 0.95rem var(--body);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
button:disabled { opacity: 0.4; cursor: default; }

button.primary {
  border-color: var(--bark);
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-deep) 100%);
  color: #2a1705;
}
button.primary:hover:not(:disabled) { border-color: var(--bark); color: #2a1705; filter: brightness(1.06); }

button.mini { min-height: 2rem; padding: 0.15rem 0.75rem; font-size: 0.85rem; }

button.danger { border-color: transparent; color: var(--terracotta); text-decoration: underline; text-underline-offset: 3px; }
button.danger:hover:not(:disabled) { border-color: transparent; color: #f0a48c; }

/* A pressed toggle, such as Show formatting. */
button[aria-pressed="true"] { border-color: var(--gold); background: rgba(243, 216, 138, 0.14); color: var(--gold); }

/* ---------- fields on the dark frame ---------- */

input[type="text"], input[type="search"], input:not([type]), select, textarea {
  min-height: var(--tap);
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(253, 246, 230, 0.28);
  border-radius: 6px;
  background: var(--forest);
  color: var(--cream);
  font: inherit;
}

input::placeholder, textarea::placeholder { color: rgba(230, 220, 198, 0.65); }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--gold); }

/* ---------- paper: where the words are ---------- */

.paper {
  background:
    radial-gradient(rgba(98, 70, 42, 0.07) 1px, transparent 1.2px) 0 0 / 7px 7px,
    var(--paper);
  color: var(--ink);
}

.paper .hint { color: var(--ink-soft); }
.paper a { color: var(--amber-ink); }
.paper code { background: rgba(98, 70, 42, 0.1); color: var(--ink); }

.paper button { border-color: var(--paper-edge); background: var(--field); color: var(--ink); }
.paper button:hover:not(:disabled) { border-color: var(--amber-ink); color: var(--amber-ink); }
.paper button.primary {
  border-color: var(--bark);
  background: linear-gradient(180deg, var(--amber) 0%, var(--amber-deep) 100%);
  color: #2a1705;
}
.paper button.danger { border-color: transparent; background: none; color: var(--rust); }

.paper input[type="text"], .paper input:not([type]), .paper select, .paper textarea {
  border-color: var(--paper-edge);
  background: var(--field);
  color: var(--ink);
}
.paper input::placeholder, .paper textarea::placeholder { color: #8f7757; }
.paper input[type="checkbox"] { accent-color: var(--amber-ink); }

/* ---------- messages ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 50;
  max-width: 70ch;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 0 var(--paper-edge), 0 14px 34px rgba(6, 14, 12, 0.55);
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; }
#toast.err { background: #fbe3c4; color: var(--ink); box-shadow: inset 4px 0 0 var(--rust), 0 14px 34px rgba(6, 14, 12, 0.55); }

dialog {
  max-width: 560px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--paper-edge), 0 18px 44px rgba(6, 14, 12, 0.55);
}
dialog::backdrop { background: rgba(6, 14, 12, 0.6); }

.empty { padding: 3rem 2rem; color: var(--ink-soft); text-align: center; font-size: 1.05rem; }
