/* ---------------------------------------------------------------------
   TODO Tool Name — style.css
   Starting point for a new Tools-Portal app. Everything up to the
   "-------- your content starts here --------" marker is the portal-wide
   contract (masthead + dark theme + page width) and should not be
   restructured — see README.md in this folder for what may/may not change.
   Below that marker, replace the placeholder example rules with your own.
   ------------------------------------------------------------------- */

:root {
  --paper: #f5f1e8;
  --paper-raised: #fffdf7;
  --ink: #1c1a15;
  --ink-soft: #5a5646;
  --ink-faint: #8a8570;
  --rule: #d8d0bc;
  --rule-strong: #b9ae8c;
  --accent: #b5482f;
  --accent-soft: #f0ded7;
  --focus: #1c1a15;
  --radius-sm: 3px;
  --radius-md: 6px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", ui-monospace, "Cascadia Mono", monospace;
}

/* ---------- Dark theme ----------
   Toggled via [data-theme="dark"] on <html> (set by the anti-FOUC inline
   script in index.html). Same token names as the light palette above are
   redefined here — every rule you write should read var(--paper)/
   var(--ink)/etc. so the whole page repaints on toggle without touching
   component styles. If you introduce your own extra color tokens (a
   category accent, a status color, ...), add BOTH a light value in :root
   above and a dark-safe value in this block — never leave one variant
   undefined (Kai.md: "Kategorie-/Akzentfarben... für Dark Mode ebenfalls
   beide Varianten pflegen"). */
html[data-theme="dark"] {
  --paper: #1b1914;
  --paper-raised: #262319;
  --ink: #ece6d6;
  --ink-soft: #b7ae95;
  --ink-faint: #8f8870;
  --rule: #3a362a;
  --rule-strong: #55503e;
  --accent: #e2825f;
  --accent-soft: #3a2620;
  --focus: #ece6d6;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.5;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Complex-script rendering (Kai.md): if this tool shows Thai or another
   non-Latin/diacritic-heavy script, give it its own generous line-height
   and visible overflow so stacked marks are never clipped. Uncomment and
   adapt — do not just reuse body's line-height: 1.5, it is too tight for
   Thai vowel/tone-mark stacks.
[lang="th"] {
  font-family: var(--font-thai), var(--font-serif);
  line-height: 1.8;
}
*/

/* ================= MASTHEAD ==================================
   Standardized 2-line header. Same class names/structure across the
   portal, web-countdown, and every tool app — DO NOT rename, DO NOT
   restructure. Copy this block verbatim into a new tool; only the
   *values* (accent color references, max-widths) may be adapted to a
   tool's own palette if it has one (see thai-flashcards/style.css for an
   example of a tool with its own jade/saffron palette reusing this exact
   block with different var() targets). */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.masthead {
  padding-bottom: 1.15rem;
}

.masthead-rule {
  border: none;
  border-top: 2px solid var(--ink);
  margin: 0 0 2.5rem;
}

.masthead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.masthead-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.home-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.home-icon:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.home-icon:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .home-icon {
    transition: none;
  }
}

.brand-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--paper);
  font-size: 1.05rem;
}

.brand-tile img {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  /* External <img> SVGs do not inherit currentColor. Brand-tile is ink-on-paper
     inverted (dark tile / paper glyph). Force monochrome paint to match. */
  filter: brightness(0) invert(1);
}
html[data-theme="dark"] .brand-tile img {
  /* Dark theme: --ink tile is light; keep icon dark. */
  filter: brightness(0);
}


.brand-title {
  font-size: clamp(1.3rem, 3.2vw, 1.6rem);
  margin: 0;
  min-width: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* If the title is (or contains) non-Latin script, replace the three
     rules above with:
       line-height: 1.8; overflow: visible; white-space: normal;
     — never truncate/clip a complex script for a short title. */
}

.brand-title-sub {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-toggle {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--paper-raised);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.theme-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Theme toggle icon cross-fade — transform/opacity only (GPU-only rule),
   skipped entirely under prefers-reduced-motion below. */
.theme-icon {
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.theme-icon--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.theme-icon--moon {
  opacity: 0;
  transform: scale(0.5) rotate(-40deg);
}

html[data-theme="dark"] .theme-icon--sun {
  opacity: 0;
  transform: scale(0.5) rotate(40deg);
}

html[data-theme="dark"] .theme-icon--moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-icon {
    transition: none;
  }
}

.masthead-sub {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
  max-width: 60ch;
}

/* ---------- Footer ---------- */

.page-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.app-version {
  margin-top: 0.35rem;
  opacity: 0.6;
}

.app-version:empty {
  display: none;
}

/* ================= your content starts here ================== */

.workspace {
  max-width: 720px;
  margin: 2.5rem auto 0;
}

.controls {
  margin-bottom: 1.25rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: min(100%, 14rem);
}

.field--grow {
  flex: 1 1 16rem;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.field select,
.field input[type="search"] {
  font: inherit;
  font-size: 1rem; /* iOS: avoid auto-zoom */
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem;
  min-height: 2.75rem;
  width: 100%;
}

.field select:focus,
.field input[type="search"]:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.meta-line {
  margin: 0.65rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
}

.link-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 0.15rem;
  border-bottom: 1px solid var(--rule);
}

.link-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  min-height: 1.4rem;
}

.link-title {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}

.link-warn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  color: #b8860b;
  cursor: help;
}

html[data-theme="dark"] .link-warn {
  color: #e6c35c;
}

.link-item--warn .link-title {
  color: var(--ink);
}

.link-title:hover,
.link-title:focus-visible {
  text-decoration: underline;
}

.link-title:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.link-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  word-break: break-all;
}

.empty-state {
  margin: 1.5rem 0 0;
  padding: 1rem 1.1rem;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

@media (max-width: 560px) {
  .control-row { flex-direction: column; align-items: stretch; }
  .field { min-width: 0; }
}
