/* Önder Protocols Viewer
 * Single-file vanilla CSS. No frameworks, no @imports — opens directly via file:// on Windows.
 */

:root {
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-soft: #f0ede4;
  --bg-hover: #ffffff;
  --text: #1a1a1a;
  --text-soft: #5a5a5a;
  --text-mute: #8a8a85;
  --line: #e0dccf;
  --line-strong: #c5bfa9;

  /* Accents — calmer than the PDF cover; still distinguishable */
  --accent: #c75e2e;       /* warm orange (matches book cover) */
  --accent-soft: #fdebe0;
  --accent-strong: #a04420;

  --y-color: #2563a3;      /* yönerge — blue */
  --y-bg: #eaf2fb;
  --as-color: #5d3fa3;     /* akış şeması — purple */
  --as-bg: #efe9fb;

  --done-bg: #ecf6ec;
  --done-text: #2c6c2f;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);

  --font-sans: "Ubuntu", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-sans);
  --font-serif: var(--font-sans);

  color-scheme: light;
}

/* ---------- dark palette ----------
 * Triggered explicitly by [data-theme="dark"] and (when [data-theme="auto"] is set)
 * by prefers-color-scheme: dark. Same custom properties — every component re-themes.
 */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131418;
  --bg-elev: #1c1e24;
  --bg-soft: #25282f;
  --bg-hover: #2a2e36;
  --text: #e6e3da;
  --text-soft: #b8b4a8;
  --text-mute: #888578;
  --line: #2e323a;
  --line-strong: #4a505a;

  --accent: #e07a4a;
  --accent-soft: #2a1a13;
  --accent-strong: #f29262;

  --y-color: #82b8e6;
  --y-bg: #182330;
  --as-color: #b6a4ec;
  --as-bg: #221b35;

  --done-bg: #1d2c1e;
  --done-text: #8fc592;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --bg: #131418;
    --bg-elev: #1c1e24;
    --bg-soft: #25282f;
    --bg-hover: #2a2e36;
    --text: #e6e3da;
    --text-soft: #b8b4a8;
    --text-mute: #888578;
    --line: #2e323a;
    --line-strong: #4a505a;
    --accent: #e07a4a;
    --accent-soft: #2a1a13;
    --accent-strong: #f29262;
    --y-color: #82b8e6;
    --y-bg: #182330;
    --as-color: #b6a4ec;
    --as-bg: #221b35;
    --done-bg: #1d2c1e;
    --done-text: #8fc592;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "cv11", "ss01"; /* Inter: open digits + single-storey "a" */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-strong); }
a:hover { color: var(--accent); }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.5rem;
  box-shadow: var(--shadow);
}
.topbar .brand { flex: 1; min-width: 0; }
.topbar h1 {
  font-size: 1.06rem; font-weight: 700; margin: 0;
  letter-spacing: -0.018em;
  font-feature-settings: "cv11", "ss01";
}
.topbar .subtitle {
  margin: .15rem 0 0; font-size: .8rem; color: var(--text-mute);
  letter-spacing: -0.005em;
}
.app-version {
  display: inline-block;
  margin-top: .9rem;
  font-size: .65rem;
  font-weight: 500;
  color: var(--text-mute);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9999px;
  padding: .1rem .55rem;
  font-feature-settings: "tnum";
  letter-spacing: .02em;
  user-select: text;
}
.topbar-actions { display: flex; gap: .6rem; align-items: center; }
.lang-switch {
  display: inline-flex; border: 1px solid var(--line-strong);
  border-radius: var(--radius); overflow: hidden; background: var(--bg);
  height: 30px;
}
.lang-switch button {
  background: transparent; border: 0; padding: 0 .8rem; cursor: pointer;
  font-family: inherit; font-size: .8rem; font-weight: 600; color: var(--text-soft);
  letter-spacing: .03em;
  height: 100%;
}
.lang-switch button.active {
  background: var(--accent); color: white;
}

/* theme switch — same chassis as lang switch, with a tiny icon font */
.theme-switch {
  display: inline-flex; border: 1px solid var(--line-strong);
  border-radius: var(--radius); overflow: hidden; background: var(--bg);
  height: 30px;
}
.theme-switch button {
  background: transparent; border: 0; cursor: pointer;
  width: 32px; height: 100%;
  font-family: inherit; font-size: 1rem; line-height: 1;
  color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.theme-switch button:hover { color: var(--text); background: var(--bg-soft); }
.theme-switch button.active {
  background: var(--accent); color: white;
}
.ghost {
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 0 .9rem;
  height: 30px;
  font-size: .82rem; font-family: inherit; color: var(--text-soft);
  cursor: pointer;
}
.ghost:hover { background: var(--bg-soft); color: var(--text); }

/* font picker */
.select-wrap {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 .5rem 0 .65rem;
  height: 30px;
}
.select-label {
  font-size: .68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-mute);
  white-space: nowrap;
}
.font-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: .82rem;
  color: var(--text);
  cursor: pointer;
  padding: 0 1.1rem 0 .25rem;
  height: 100%;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 9px) 53%, calc(100% - 4px) 53%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.font-select:focus { outline: 0; }
.select-wrap:hover { border-color: var(--accent); }
.select-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------------- layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 64px);
}
.sidenav {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 1.4rem 1rem;
  position: sticky; top: 64px;
  align-self: start;
  height: calc(100vh - 64px);
  overflow-y: auto;
}
.sidenav h2 {
  margin: 0 .5rem 1rem; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em; color: var(--text-mute);
}
.sidenav ol { list-style: none; padding: 0; margin: 0; }
.sidenav li { margin: 0; padding: 0; }
.sidenav a {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .6rem .65rem; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.sidenav a:hover { background: var(--bg-soft); }
.sidenav a.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.nav-num {
  font-family: var(--font-sans); font-size: .8rem;
  color: var(--text-mute); flex: 0 0 auto;
  font-feature-settings: "tnum", "cv11"; letter-spacing: .01em;
  padding-top: .2rem;
  font-weight: 500;
}
.nav-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.nav-title { font-size: .92rem; font-weight: 600; line-height: 1.35; }
.nav-age { font-size: .76rem; color: var(--text-mute); }
.source-note {
  font-size: .72rem; color: var(--text-mute);
  margin-top: 1.6rem; padding-top: 1rem;
  border-top: 1px solid var(--line); line-height: 1.4;
}

/* ---------------- main content ---------------- */
.content {
  padding: 2rem 2.4rem 4rem;
  max-width: 64rem;
}
.izlem-head h2 {
  font-family: var(--font-sans);
  font-size: 2rem; font-weight: 700;
  margin: 0 0 .35rem;
  letter-spacing: -0.015em;
  line-height: 1.18;
  color: var(--accent-strong);
}
.izlem-head .age {
  font-style: italic; color: var(--text-soft); margin: 0 0 .4rem;
  font-size: .92rem;
}
/* ---------- Progress bars (shared) ---------- */
.progress {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.progress-bar {
  position: relative;
  flex: 0 0 auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  border-radius: inherit;
  transition: width .35s cubic-bezier(.2,.8,.2,1), background .25s ease;
}
.progress-text { color: var(--text); font-weight: 600; }
.progress-percent { color: var(--text-mute); font-weight: 500; }
.progress.is-empty .progress-fill { background: var(--line-strong); opacity: .35; }
.progress.is-complete .progress-fill {
  background: linear-gradient(90deg, #2f9e57, #1f7a40);
}
.progress.is-complete .progress-text,
.progress.is-complete .progress-percent { color: var(--done-text); }

/* main progress (top of izlem) — large + prominent */
.izlem-head .progress.progress--main {
  margin: .9rem 0 .25rem;
  font-size: .9rem;
}
.izlem-head .progress--main .progress-bar {
  width: 240px; height: 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.04);
}
.izlem-head .progress--main .progress-percent {
  margin-left: auto;
  font-size: .82rem;
}
@media (max-width: 720px) {
  .izlem-head .progress--main .progress-bar { width: 60vw; max-width: 240px; }
}
.medical-note {
  font-size: .78rem; color: var(--text-mute);
  margin: .6rem 0 1.4rem; padding-left: .9rem;
  border-left: 3px solid var(--line);
}

/* table of contents */
.toc {
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: .8rem 1.1rem;
  margin: 0 0 2rem;
  font-size: .85rem;
}
.toc-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute); margin-bottom: .4rem;
}
.toc ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 1.5rem; }
.toc li { break-inside: avoid; padding: .15rem 0; }
.toc a { color: var(--text-soft); text-decoration: none; }
.toc a:hover { color: var(--accent-strong); text-decoration: underline; }

/* sections */
.sec { margin-bottom: 2.4rem; }
.sec-heading {
  font-family: var(--font-sans);
  font-size: 1.05rem; font-weight: 700;
  margin: 1.8rem 0 .55rem;
  padding-bottom: .4rem;
  letter-spacing: -0.012em;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 80px;
  text-transform: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .8rem;
}
.sec-heading-label { flex: 1 1 auto; min-width: 0; position: relative; padding-left: .8rem; }
.sec-heading-label::before {
  content: '';
  position: absolute;
  left: 0; top: .15em; bottom: .15em;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
}

/* mini progress (per-section heading) — compact, lives at the right edge of the heading */
.progress.progress--mini {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 600;
  gap: .45rem;
}
.progress--mini .progress-bar {
  width: 90px; height: 6px;
}
.progress--mini .progress-text { color: var(--text-mute); font-weight: 600; }
.progress--mini .progress-percent { color: var(--text-mute); font-weight: 500; min-width: 2.6em; text-align: right; }
@media (max-width: 560px) {
  .progress--mini .progress-bar { width: 60px; }
  .progress--mini .progress-percent { display: none; }
}
.sec-lead {
  font-size: .92rem; color: var(--text-soft);
  margin: .25rem 0 .9rem; font-style: italic;
  max-width: 50rem;
}

/* ---------------- step grid + cards ---------------- */
.sec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
  align-items: stretch;
}

/* Group header — spans the full row, sits between cards as a divider/subheading. */
.group-header {
  grid-column: 1 / -1;
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: .55rem .8rem;
  border-radius: var(--radius-sm);
  margin: .4rem 0 .15rem;
}

.step-card {
  position: relative;
  display: flex; flex-direction: column;
  gap: .65rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1rem .85rem 1rem;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease, transform .15s ease;
}
.step-card::before {
  /* Subtle accent stripe along the left edge — emphasizes the card boundary without a heavy border. */
  content: '';
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  background: var(--line);
  border-radius: 0 2px 2px 0;
  transition: background .15s ease;
}
.step-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  transform: translateY(-1px);
}
.step-card:hover::before { background: var(--accent); }
.step-card.checked {
  background: var(--done-bg);
  border-color: #c1dec3;
}
.step-card.checked::before { background: var(--done-text); }
.step-card.checked .step-text {
  color: var(--text-mute);
  text-decoration: line-through;
}

/* Number badge — sits in the top-right corner as a quiet ordinal indicator. */
.step-number {
  position: absolute;
  top: .55rem;
  right: .7rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text-mute);
  font-feature-settings: "tnum";
  user-select: none;
  pointer-events: none;
  opacity: .7;
  transition: color .15s ease, opacity .15s ease;
}
.step-number::before { content: '#'; opacity: .5; margin-right: 1px; }
.step-card:hover .step-number { color: var(--accent-strong); opacity: 1; }
.step-card.checked .step-number { opacity: .5; }

.step-card-row {
  display: flex; gap: .65rem; align-items: flex-start;
  cursor: pointer;
  padding-right: 2rem; /* avoid colliding with the number badge */
}
.step-checkbox {
  flex: 0 0 auto; margin-top: .2rem;
  width: 1.2rem; height: 1.2rem;
  cursor: pointer; accent-color: var(--accent);
}
.step-text {
  font-size: .96rem;
  line-height: 1.45;
  font-weight: 500;
  color: var(--text);
}

/* Reference chips at the bottom of the card. */
.step-card-refs {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin-top: auto; /* push to the bottom of the card so cards align nicely */
  padding-top: .15rem;
}
.ref-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line);
  border-radius: 9999px;
  padding: .2rem .65rem .2rem .25rem;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: .76rem;
  cursor: pointer;
  max-width: 100%;
  min-width: 0;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.ref-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.ref-chip:active { transform: scale(0.98); }
.ref-chip-id {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15rem .5rem;
  border-radius: 9999px;
  background: var(--bg-elev);
}
.ref-chip.kind-y .ref-chip-id { background: var(--y-bg); color: var(--y-color); }
.ref-chip.kind-as .ref-chip-id { background: var(--as-bg); color: var(--as-color); }
.ref-chip-title {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-soft);
  font-weight: 500;
}

.ref-tag {
  display: inline-block;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .045em;
  padding: .18rem .55rem; border-radius: 9999px;
  background: var(--bg-soft); color: var(--text-soft);
  font-feature-settings: "tnum";
  flex: 0 0 auto;
}
.ref-tag.y { background: var(--y-bg); color: var(--y-color); }
.ref-tag.as { background: var(--as-bg); color: var(--as-color); }
.ref-tag.large { font-size: .8rem; padding: .3rem .7rem; }

/* ---------------- modal (referenced page viewer) ---------------- */
.ref-modal {
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: var(--bg-elev);
  color: var(--text);
  max-width: min(96vw, 1100px);
  width: 100%;
  max-height: 92vh;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  position: fixed;
  inset: 0;
  margin: auto;
}
.ref-modal::backdrop {
  background: rgba(15, 18, 24, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-body {
  overflow-y: auto;
  max-height: 92vh;
  padding: 1.4rem 1.6rem 1.8rem;
  scrollbar-gutter: stable;
}
.modal-close {
  position: absolute;
  top: .5rem; right: .65rem;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0; border-radius: 50%;
  color: var(--text-mute);
  font-size: 1.45rem; line-height: 1;
  cursor: pointer;
  z-index: 1;
  transition: background .12s ease, color .12s ease;
}
.modal-close:hover { background: var(--bg-soft); color: var(--text); }

.modal-header {
  display: flex; flex-direction: column; gap: .35rem;
  padding-bottom: .85rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-right: 2.5rem; /* clear of the close button */
}
.modal-header .ref-tag { align-self: flex-start; }
.modal-title {
  margin: 0;
  font-size: 1.4rem; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}
.modal-page {
  margin: 0;
  font-size: .8rem; color: var(--text-mute);
}

.modal-imgs {
  display: flex; flex-direction: column; gap: .8rem;
}
.modal-imgs img {
  max-width: 100%; height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

.modal-ocr {
  margin-top: 1.2rem;
  border-top: 1px dashed var(--line);
  padding-top: .8rem;
  font-size: .9rem;
}
.modal-ocr > summary {
  cursor: pointer; font-size: .82rem; color: var(--text-mute);
  user-select: none;
  padding: .25rem 0;
}
.modal-ocr > summary:hover { color: var(--accent-strong); }
.modal-ocr .ref-body p {
  color: var(--text-soft);
  font-size: .88rem;
  margin: .25rem 0;
  line-height: 1.5;
}
.ref-body ul, .ref-body ol { margin: .35rem 0; padding-left: 1.3rem; }
.ref-body li { margin: .15rem 0; }
.ref-table {
  border-collapse: collapse; margin: .6rem 0;
  font-size: .85rem;
}
.ref-table th, .ref-table td {
  border: 1px solid var(--line); padding: .35rem .55rem; text-align: left;
}
.ref-table th { background: var(--bg-soft); font-weight: 600; }

/* izlem-level image (özet tablo) */
.izlem-image-wrap {
  margin: 1rem 0 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .75rem 1rem;
}
.izlem-image-wrap > summary {
  cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-soft);
}
.izlem-image {
  width: 100%; height: auto;
  margin-top: .8rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: white;
}

.foot {
  margin-top: 3rem; padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--text-mute);
}
.foot a { text-decoration: none; }

/* ---------------- responsive ---------------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav {
    position: relative; top: 0;
    height: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .content { padding: 1.5rem 1.2rem 3rem; }
  .toc ul { columns: 1; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { flex-wrap: wrap; }
  .select-label { display: none; }
}

/* ---------------- print ---------------- */
@media print {
  .topbar, .sidenav, .toc, .ghost, .lang-switch, .theme-switch, .select-wrap { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .izlem-image-wrap { border: 0; padding: 0; }
  .izlem-image-wrap > summary { display: none; }
  /* Cards print one per row, never split across pages. */
  .sec-grid { display: block; }
  .step-card { break-inside: avoid; page-break-inside: avoid; margin-bottom: .6rem; }
  .step-card { background: transparent !important; border-color: #999 !important; }
  /* The modal is overlay UI — never paginated. */
  .ref-modal { display: none !important; }
  body { font-size: 11pt; line-height: 1.4; background: white; }
  .izlem-head h2 { font-size: 18pt; }
  .sec-heading { font-size: 13pt; }
}
