/* Rectorate Email Generator — visual identity matches the reallyctu.cz to-do list
   (the checklist palette), applied to an official-memo layout. */

:root {
  --paper: #fffdf6;
  --bg: #f6f1e6;
  --ink: #221c12;
  --muted: #6f6757;
  --border: #ddd3bd;
  --accent: #0065bd;
  --accent-contrast: #ffffff;
  --accent-soft: #e4eff9;
  --navy: #002d56;
  --shadow: 0 1px 2px rgba(34, 28, 18, 0.08), 0 4px 14px rgba(34, 28, 18, 0.06);
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* manual dark theme (theme button) — keep in sync with the media query */
[data-theme="dark"] {
  --paper: #182029;
  --bg: #10151c;
  --ink: #e8edf4;
  --muted: #9aa7b5;
  --border: #2c3844;
  --accent: #7cb8f2;
  --accent-contrast: #0d1b2a;
  --accent-soft: #17273a;
  --navy: #a9cdf2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* auto (no data-theme attribute): follow the device setting */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #182029;
    --bg: #10151c;
    --ink: #e8edf4;
    --muted: #9aa7b5;
    --border: #2c3844;
    --accent: #7cb8f2;
    --accent-contrast: #0d1b2a;
    --accent-soft: #17273a;
    --navy: #a9cdf2;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

/* prominent satire notice, in the checklist palette */
.tape {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 8px 52px;
}

.tape .icon-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px;
  line-height: 0;
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.tape .icon-btn:hover {
  background: var(--accent);
  color: var(--accent-contrast);
}

.masthead { text-align: center; padding: 42px 20px 8px; }

.masthead .title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4vw, 2.3rem);
  margin: 0;
  color: var(--navy);
}

.title-en {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2.8vw, 1.45rem);
  margin: 2px 0 0;
  color: var(--muted);
}

main { flex: 1 0 auto; width: 100%; max-width: 960px; margin: 0 auto; padding: 8px 20px 40px; }

.controls { margin-top: 26px; }

.row {
  display: flex;
  gap: 14px;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
}

.depthbox {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.depthbox label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }

#depth {
  width: 190px;
  margin: 0;
  accent-color: var(--depth-color, var(--accent));
}

.ticks {
  display: flex;
  justify-content: space-between;
  width: 190px;
  font-size: 0.75rem;
  color: var(--muted);
}

@keyframes papershake {
  0% { transform: translateX(0); }
  25% { transform: translateX(calc(var(--shake, 2px) * -1)); }
  50% { transform: translateX(var(--shake, 2px)); }
  75% { transform: translateX(calc(var(--shake, 2px) * -0.6)); }
  100% { transform: translateX(0); }
}

.depthbox.shaking {
  animation: papershake 0.22s infinite;
}

#depth:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.before {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 18px 20px 0;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 14px;
}

button:hover { background: var(--ink); color: var(--bg); }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  padding: 12px 28px;
  font-size: 1.05rem;
}

.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  filter: brightness(1.12);
}

.output { margin-top: 10px; }

.docmeta {
  text-align: center;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  margin: 18px 0 0;
}

.paper {
  background: var(--paper);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 24px 26px 14px;
  margin: 16px 0 0;
}

.paper pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.6;
}

.paper a, .timeout-back a { color: var(--accent); }
.paper a:hover, .timeout-back a:hover { text-decoration-thickness: 2px; }

.document-link-block { display: block; white-space: normal; }
.document-link-block > a { display: block; text-underline-offset: 0.16em; }
.document-link-cue {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin: 0 0 5px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: italic 0.84rem/1.4 var(--serif);
  text-align: left;
}
.document-link-cue:hover { background: transparent; color: var(--accent); }
.document-link-cue [lang="en"]::before { content: " / "; }
.document-link-cue-letter {
  opacity: 0.55;
  animation: cue-letter-wave 3.2s ease-in-out infinite;
}
.document-link-cue-arrow {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
  animation: point-to-document 2.4s ease-in-out infinite;
}
.document-link-cue:focus-visible, .document-link-block > a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
@keyframes point-to-document {
  0%, 50%, 100% { transform: translateY(0); }
  65%, 85% { transform: translateY(4px); }
  75% { transform: translateY(1px); }
}
@keyframes cue-letter-wave {
  0%, 30%, 100% { opacity: 0.55; }
  12% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .document-link-cue-arrow { animation: none; }
  .document-link-cue-letter { animation: none; opacity: 1; }
}

.timeout-page { margin: 24px auto; max-width: 820px; }
.timeout-document { font-weight: 400; margin-bottom: 20px; }
.timeout-window {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.timeout-window-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.timeout-window-controls { display: flex; gap: 5px; justify-self: start; }
.timeout-window-controls i { width: 8px; height: 8px; border-radius: 50%; background: #e76a62; }
.timeout-window-controls i:nth-child(2) { background: #e6b950; }
.timeout-window-controls i:nth-child(3) { background: #72b485; }
.timeout-window-runtime { font-weight: 700; text-align: center; white-space: nowrap; }
.timeout-window-number { justify-self: end; font-variant-numeric: tabular-nums; }
.timeout-window-content { padding: 20px 24px; text-align: center; }
.timeout-title {
  color: var(--navy);
  font-family: var(--serif);
  font-size: clamp(1.5rem, 5vw, 2rem);
  overflow-wrap: anywhere;
}
.timeout-title span { display: block; }
.timeout-title [lang="en"] { color: var(--muted); }
.timeout-login { margin: 16px 0 0; padding: 10px 18px; }
.timeout-window-child { padding: 12px; }
.timeout-window-child:empty { display: none; }
.timeout-window.has-child > .timeout-window-content { padding: 8px 12px 0; opacity: 0.6; }
.timeout-window.has-child > .timeout-window-content > .timeout-title { font-size: 1rem; margin: 0; }
.timeout-window.has-child > .timeout-window-content > .timeout-title span { display: inline; }
.timeout-window.has-child > .timeout-window-content > .timeout-title [lang="en"]::before { content: " / "; }
.timeout-window.has-child > .timeout-window-content > :not(.timeout-title) { display: none; }
.timeout-window.is-folded { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
.timeout-window.is-folded > .timeout-window-bar,
.timeout-window.is-folded > .timeout-window-content { display: none; }
.timeout-window.is-folded > .timeout-window-child { padding: 0; }
.authenticator-challenge {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-top: 20px;
  background: var(--accent-soft);
}
.authenticator-name { margin: 0 0 12px; font-weight: 700; color: var(--navy); }
.authenticator-instructions { font-size: 0.9rem; line-height: 1.5; margin: 8px 0; }
.authenticator-code { display: flex; justify-content: center; gap: 10px; margin-top: 16px; }
.authenticator-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.5em;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--paper);
  color: var(--navy);
  font: 700 2.5rem/1 ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.timeout-back { text-align: center; }

@media (max-width: 600px) {
  .timeout-window-child { padding: 8px 3px 4px; }
  .timeout-window-content { padding: 14px 12px; }
  .timeout-window-bar { gap: 6px; padding: 8px; font-size: 0.72rem; }
  .timeout-window-controls { gap: 3px; }
  .timeout-window-controls i { width: 6px; height: 6px; }
  .authenticator-challenge { padding: 12px 8px; }
}

.paperhead, .paperfoot { display: flex; justify-content: flex-end; }
.paperhead { margin-bottom: 12px; }
.paperfoot { margin-top: 12px; }

.paperhead .copy, .paperfoot .copy { font-size: 0.9rem; }

footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 30px;
  padding: 16px 20px 30px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

footer p { margin: 6px auto; }

.presented { font-weight: 800; color: var(--ink); letter-spacing: 0.02em; }
