/* ═══════════════════════════════════════════════════════════════
   JINÉ PÍSMO — překladač Jiného písma
   Two display modes, switched on <html data-mode="color|bw">.

   color  → barevná: translator zones green / periwinkle, the Abeceda
            and portfolio carry the six semantic group colours.
   bw     → černobílá: chrome desaturates to white + grey; the
            portfolio keeps its category colours (the legend / key).
   ═══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Jine';
  src: url('assets/fonts/jinepismo-jine.otf?v=4') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  /* Glyph fallback. scripts/extend-jinepismo.py maps the new font's
     alternate glyphs onto the engine's codepoints (Þ noha, ȟ blízko,
     dingbats, oko/teď/potom/vidět, f_i Bůh…). Inkove still backs the
     invented diacritic variants the new font doesn't draw. */
  font-family: 'Inkove';
  src: url('assets/fonts/inkove-Regular.otf?v=9') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Stare';
  src: url('assets/fonts/starepismo-Regular.ttf?v=2') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  /* semantic group colours (kap. ROZDĚLENÍ), sampled from the specimen PDF */
  --telo:       #C22025;
  --priroda:    #007345;
  --cas:        #FEC800;
  --humanitni:  #1C2D72;
  --vizualni:   #E7480F;
  --nevizualni: #D385B7;


  --ink:  #15140f;
  --bg:   #ffffff;
  --line: #15140f;
  --grey-fill: #b9b9b9;
  --grey-cell: #8d8d8d;

  --serif: 'Stare', 'Spectral', Georgia, 'Times New Roman', serif;
  --body: 'Spectral', Georgia, serif;
  --win-h: 140px;   /* shared height for every translator window */
  --maxw: 1180px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: clamp(20px, 4vw, 56px) clamp(16px, 4vw, 56px) 96px;
  display: flex;
  justify-content: center;
}

.container { width: 100%; max-width: var(--maxw); }

/* ─────────────────────────── HEADER ─────────────────────────── */
.hd {
  margin-bottom: clamp(16px, 2.2vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.hd h1 {
  font-size: clamp(20px, 2.1vw, 27px);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  line-height: 1;
}

/* mode switch */
.modeswitch {
  display: inline-flex;
  align-items: stretch;
  min-height: 34px;            /* match the search input height */
  border: 1.5px solid var(--line);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  user-select: none;
}
.modeswitch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  padding: 0 14px;             /* vertical centering comes from the height */
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
}
.modeswitch button + button { border-left: 1.5px solid var(--line); }
.modeswitch button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* language switch — same chrome as the mode switch, lives in the header;
   two square buttons, the label optically centred (letter-spacing adds a
   trailing gap after the last letter, so the text is nudged right by it) */
.langswitch { min-height: 34px; }
.langswitch button {
  box-sizing: border-box;
  width: 34px;
  height: 34px;
  /* caps sit high in this face: measured 2.25px above the optical centre,
     so the content box is pushed down by twice that */
  padding: 4.5px 0 0 0.16em;
  justify-content: center;
  line-height: 1;
}
/* per-word optical nudge (measured ink gaps): Z's foot reaches right, N's serifs do not */
.langswitch button[lang="cs"] { padding-left: 0.08em; }
.langswitch button[lang="en"] { padding-left: 0.26em; }

/* ───────────────────────── TRANSLATOR ───────────────────────── */
.translator {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}
/* explicit row/column placement so the two columns align row-by-row,
   with Interpretace as an extra box under Slova on the right. */
.t-a { grid-column: 1; grid-row: 1; }
.t-b { grid-column: 2; grid-row: 1; }
.t-c { grid-column: 1; grid-row: 2; }
.t-d { grid-column: 2; grid-row: 2; }
.t-e { grid-column: 2; grid-row: 3; }
.zone { display: flex; flex-direction: column; gap: 16px; }

.frame {
  border: 1.5px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* the input/output area fills the frame so stretched rows stay aligned */
.frame > textarea,
.frame > .cs-output,
.frame > .tokens,
.frame > .output { flex: 1 1 auto; }
.frame .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 9px 14px;
  border-bottom: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* translator windows are plain white in both modes */
.z-cz, .z-gl { background: #fff; }

textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  color: var(--ink);
  outline: none;
  padding: 14px;
}
#cs-input {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.5;
  min-height: var(--win-h);
}
#cs-input::placeholder, #gl-input::placeholder { color: var(--ink); opacity: 0.5; font-style: italic; }
/* Čeština hint is upright Staré písmo (inherits #cs-input's font). */
#cs-input::placeholder { font-style: normal; }
/* Glyfy hint is the cipher glyph for "ahoj" — render it in the cipher
   font at the input's glyph size, upright. */
#gl-input::placeholder { font-family: 'Jine', 'Inkove', serif; font-size: 30px; letter-spacing: 0.04em; font-style: normal; }
#gl-input {
  font-family: 'Jine', 'Inkove', serif;
  font-size: 30px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  min-height: var(--win-h);
  font-feature-settings: 'liga' 1, 'dlig' 1;
  font-variant-ligatures: common-ligatures discretionary-ligatures;
}

.cs-output {
  padding: 14px;
  font-family: 'Jine', 'Inkove', serif;
  font-size: 30px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  min-height: var(--win-h);
  word-break: break-word;
  font-feature-settings: 'liga' 1, 'dlig' 1;
  font-variant-ligatures: common-ligatures discretionary-ligatures;
}
.tokens {
  padding: 14px;
  min-height: var(--win-h);
  font-size: 16px;
  line-height: 1.85;
}
.tokens .gly { font-weight: 600; }
.tokens .sep { margin: 0 5px; opacity: 0.5; }
.tokens .unk { text-decoration: underline dotted; text-underline-offset: 3px; }
.output {
  padding: 14px;
  font-size: 18px;
  line-height: 1.7;
  min-height: var(--win-h);
}
.muted { font-style: italic; opacity: 0.55; font-size: 14px; }

/* ─────────────────────────── ABECEDA ─────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 0 14px;
  border-bottom: 1.5px solid var(--line);
  padding-bottom: 8px;
}
.section-head h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.section-head .hint { font-size: 12px; font-style: italic; opacity: 0.55; }

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

#search {
  border: 1.5px solid var(--line);
  padding: 7px 11px;
  font-size: 12px;
  font-family: var(--serif);
  letter-spacing: 0.06em;
  background: #fff;
  color: var(--ink);
  outline: none;
  min-height: 34px;
  width: 200px;
  max-width: 46vw;
}

.keygrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.kcell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: var(--gc, var(--grey-cell));
  transition: transform 0.08s ease, filter 0.12s ease;
}
[data-mode="bw"] .kcell { background: var(--ink); }
.kcell:hover { filter: brightness(1.07); transform: translateY(-1px); }
[data-mode="bw"] .kcell:hover { filter: none; background: #2a2924; }
.kcell:active { transform: translateY(0); }
.kg {
  font-family: 'Jine', 'Inkove', serif;
  font-size: 36px;
  line-height: 1;
  color: #fff;
  font-feature-settings: 'liga' 1, 'dlig' 1;
  font-variant-ligatures: common-ligatures discretionary-ligatures;
}
.kw {
  font-size: 10px;
  letter-spacing: 0.03em;
  color: #fff;
  text-align: center;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.92;
}
.kcell.has-menu::after {
  content: '';
  position: absolute;
  right: 6px; top: 6px;
  width: 5px; height: 5px;
  background: #fff; opacity: 0.7;
  border-radius: 50%;
}

/* ─────────────────────── PICKER MENU ─────────────────────── */
.gmenu {
  position: absolute;
  z-index: 50;
  min-width: 168px;
  max-width: 260px;
  border: 1.5px solid var(--line);
  background: #fff;
  box-shadow: 4px 4px 0 var(--ink);
  display: flex;
  flex-direction: column;
}
.gmenu[hidden] { display: none; }
.gmenu-item {
  appearance: none; border: 0;
  border-bottom: 1.5px solid var(--line);
  background: #fff; color: var(--ink);
  padding: 9px 13px;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--serif); font-size: 14px;
  text-align: left; cursor: pointer; min-height: 42px;
}
.gmenu-item:last-child { border-bottom: 0; }
.gmenu-item:hover { background: var(--ink); color: #fff; }
.gmenu-g {
  font-family: 'Jine', 'Inkove', serif; font-size: 24px; line-height: 1;
  min-width: 30px; text-align: center;
  font-feature-settings: 'liga' 1, 'dlig' 1;
}
.gmenu-w { flex: 1; }

/* ─────────────────────────── PORTFOLIO ─────────────────────────── */
.portfolio { margin-top: 16px; }
.legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cat {
  appearance: none;
  text-align: left;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-family: var(--serif);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.1s ease;
}
.cat:hover { transform: translateY(-2px); }
.cat-bar {
  height: 52px;
  background: var(--gc);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1.5px solid var(--line);
}
.cat-name {
  font-size: 15px; font-weight: 600;
  letter-spacing: 0.04em; color: var(--gc-ink, #fff);
  text-transform: uppercase;
}
.cat-body { padding: 12px 16px 14px; display: block; }
.cat-blurb { display: block; font-size: 12.5px; line-height: 1.5; opacity: 0.78; }
.cat-meta {
  display: block; margin-top: 10px; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.5;
}
.cat[aria-expanded="true"] { outline: 3px solid var(--gc); outline-offset: -1.5px; }

/* expanded detail. Desktop: placed after the whole legend, merging under
   it (margin -1.5px). Mobile: placed inside the legend grid after the
   tapped card, spanning full width — see the mobile overrides below. */
.detail {
  grid-column: 1 / -1;
  border: 1.5px solid var(--line);
  border-top: none;
  margin-top: -1.5px;
  display: none;
}
.detail.open { display: block; }
.detail-head {
  background: var(--gc);
  padding: 14px 18px;
  border-bottom: 1.5px solid var(--line);
}
.detail-head .dn { font-size: 17px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gc-ink, #fff); }
.detail-head .db { font-size: 13px; line-height: 1.5; color: var(--gc-ink, #fff); opacity: 0.95; margin-top: 6px; max-width: 70ch; }
.signlist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
}
.signrow {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-align: left;
  font-family: var(--serif);
  color: var(--ink);
  background: #fff;
  appearance: none;
  padding: 13px 16px;
  border: none;
  border-bottom: 1.5px solid var(--line);
  border-right: 1.5px solid var(--line);
  cursor: pointer;
}
.signrow:hover { background: color-mix(in srgb, var(--gc) 12%, #fff); }
.sign-g {
  font-family: 'Jine', 'Inkove', serif;
  font-size: 34px; line-height: 1;
  width: 46px; text-align: center; flex: none;
  color: var(--gc);
  font-feature-settings: 'liga' 1, 'dlig' 1;
}
[data-mode="bw"] .sign-g { color: var(--ink); }
.sign-txt { min-width: 0; }
.sign-w { font-size: 15px; font-weight: 600; letter-spacing: 0.02em; }
.sign-e { font-size: 12.5px; line-height: 1.5; opacity: 0.72; margin-top: 3px; }

/* ─────────────────────────── FOOTER ─────────────────────────── */
.ft {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1.5px solid var(--line);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.6;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─────────────────────────── VZORNÍK (PDF) ─────────────────────────── */
/* The bound thesis as a booklet sitting on the page: two leaves either
   side of a spine shadow, stacked page edges on the outer sides, and a
   bending 3D page turn (see book-viewer.js for the choreography). */
.pdfviewer { margin-top: 16px; }
.pdf-frame { background: transparent; }
.pdf-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 0 36px;
  min-height: 240px;
  overflow: visible;
}

.book {
  position: relative;
  transition: transform .6s cubic-bezier(.4,.1,.2,1);
}
/* a closed book sits centred on its single page */
.book.closed-front { transform: translateX(-25%); }
.book.closed-back  { transform: translateX(25%); }

.leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18), 0 12px 28px rgba(0,0,0,0.18);
}
.leaf-l { left: 0; }
.leaf-r { left: 50%; }
.leaf canvas { display: block; width: 100%; height: 100%; }
.leaf[hidden], .stack[hidden], .flip[hidden] { display: none; }

/* the fold is drawn on one canvas over both pages; the spine shadow
   sits above it so the gutter looks the same at rest and mid-turn */
.flip {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 3;
  pointer-events: none;
}

/* spine: a soft shadow falling into the gutter, deeper on the right page */
.spine {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 12%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(to right,
    rgba(0,0,0,0)    0%,
    rgba(0,0,0,0.06) 36%,
    rgba(0,0,0,0.16) 49%,
    rgba(0,0,0,0.22) 50%,
    rgba(0,0,0,0.14) 52%,
    rgba(0,0,0,0.05) 70%,
    rgba(0,0,0,0)    100%);
}
.book.closed-front .spine, .book.closed-back .spine { display: none; }
/* same gradient again, faded in by the script while a page turns */
.spine-deep { opacity: 0; z-index: 5; }

/* stacked page edges: thin alternating stripes, width set by the script
   to reflect how many leaves lie on each side */
.stack {
  position: absolute;
  top: 2px; bottom: 2px;
  width: 8px;
  background: repeating-linear-gradient(to right, #f7f7f7 0 1px, #c4c4c4 1px 2px);
  pointer-events: none;
}
.stack-r { left: 100%; border-right: 1px solid #b4b4b4; }
.stack-l { right: 100%; border-left: 1px solid #b4b4b4; }

.pdf-loading {
  position: absolute;
  font-style: italic;
  font-size: 14px;
  opacity: 0.6;
  z-index: 4;
}
.pdf-loading[hidden] { display: none; }

.pdf-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 0;
}
.pdf-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  width: 46px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--serif);
}
.pdf-btn:hover { color: #000; transform: translateY(-1px); }
.pdf-btn:disabled { opacity: 0.25; cursor: default; transform: none; }

/* ─────────────────────────── MOBILE ─────────────────────────── */
@media (max-width: 760px) {
  .pdf-stage { padding: 18px 0 26px; }
  .translator { grid-template-columns: 1fr; }
  /* collapse to one column: reset the explicit 2-col placement so the
     five windows stack instead of overlapping. Order groups the Čeština
     side (input + glyph output) above the Glyfy side (input, words,
     interpretation). */
  .t-a { grid-column: 1; grid-row: 1; }
  .t-c { grid-column: 1; grid-row: 2; }
  .t-b { grid-column: 1; grid-row: 3; }
  .t-d { grid-column: 1; grid-row: 4; }
  .t-e { grid-column: 1; grid-row: 5; }
  .legend { grid-template-columns: 1fr; }
  /* panel opens under the tapped card inside the single-column grid: pull
     it up over the 10px row-gap, and hide the header (the card above
     already shows the group name + blurb). */
  .detail { margin-top: calc(-10px - 1.5px); }
  .detail .detail-head { display: none; }
  .signlist { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .keygrid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
  .kg { font-size: 24px; }
  #gl-input, .cs-output { font-size: 24px; }
}
