/* Doktora grādi Latvijā — styles
   Palette: cool paper, blue-black ink, slate, rule grey, Latvian carmine as the single accent. */

:root {
  --paper: #FBFBFC;
  --surface: #FFFFFF;
  --ink: #1E2433;
  --slate: #5C6575;
  --rule: #DCDFE5;
  --rule-soft: #ECEEF2;
  --carmine: #9E3039;
  --carmine-tint: #F6E9EA;
  --bar: #A7AEBC;
  --bar-hover: #6F7889;
  --row-hover: #F3F4F7;
  --shadow: 0 0 0 1px rgba(30, 36, 51, .06), 0 24px 48px -12px rgba(30, 36, 51, .28);

  --serif: "Literata", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --s-1: 0.8125rem;  /* 13 */
  --s0: 0.9375rem;   /* 15 */
  --s1: 1.0625rem;   /* 17 */
  --s2: 1.3125rem;   /* 21 */
  --s3: 1.75rem;     /* 28 */
  --s4: 2.375rem;    /* 38 */

  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12151C;
    --surface: #191D26;
    --ink: #E6E8ED;
    --slate: #A1A8B6;
    --rule: #2D3341;
    --rule-soft: #232834;
    --carmine: #E2737D;
    --carmine-tint: #3A2328;
    --bar: #4F5768;
    --bar-hover: #8A93A5;
    --row-hover: #1F2430;
    --shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 24px 48px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12151C;
  --surface: #191D26;
  --ink: #E6E8ED;
  --slate: #A1A8B6;
  --rule: #2D3341;
  --rule-soft: #232834;
  --carmine: #E2737D;
  --carmine-tint: #3A2328;
  --bar: #4F5768;
  --bar-hover: #8A93A5;
  --row-hover: #1F2430;
  --shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 24px 48px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--s0)/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
body.locked { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--carmine); outline-offset: 2px; border-radius: 2px; }

.vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { top: 8px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------------------------------------------------------------- masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--surface); }
.mast { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-top: 36px; padding-bottom: 28px; }
h1 {
  font: 600 var(--s4)/1.1 var(--serif);
  letter-spacing: -0.01em;
  margin: 0 0 10px;
}
h1 .range { font-weight: 400; color: var(--slate); white-space: nowrap; }
.lede { margin: 0; max-width: 68ch; color: var(--slate); font-size: var(--s1); }
.byline { margin: 10px 0 0; font-size: var(--s-1); font-weight: 600; color: var(--ink); }

.lang { display: flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; flex: none; }
.lang button {
  border: 0; background: transparent; padding: 6px 12px; cursor: pointer;
  font-size: var(--s-1); font-weight: 600; color: var(--slate);
}
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* ---------------------------------------------------------------- controls */
.controls { padding: 28px 0 8px; }

.search { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.search-icon { position: absolute; left: 14px; top: 15px; width: 20px; height: 20px; color: var(--slate); pointer-events: none; }
#q {
  flex: 1 1 420px;
  min-width: 0;
  height: 50px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-size: var(--s1);
}
#q::placeholder { color: var(--slate); opacity: .8; }
#q:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--carmine-tint); }

.check { display: inline-flex; align-items: center; gap: 8px; color: var(--slate); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--carmine); margin: 0; }

/* Year and month ribbons: a bar chart that is also the filter. */
.ribbons { display: grid; grid-template-columns: var(--rcols, 10fr 12fr); gap: 40px; margin: 30px 0 22px; }
.ribbon { container-type: inline-size; min-width: 0; }
.bar-x .xs { display: none; }
@container (max-width: 640px) {
  .bar-x .xl { display: none; }
  .bar-x .xs { display: inline; }
}
@container (max-width: 520px) {
  #years .bars { gap: 2px; }
  #years .bar-n { font-size: 9px; letter-spacing: -0.04em; }
}
.ribbon-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; min-height: 22px; }
.ribbon-label { font-weight: 600; }
.ribbon-value { color: var(--carmine); font-weight: 600; }
.link-btn {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--slate); text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.link-btn:hover { color: var(--ink); }

.bars { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; height: 128px; }
.bar {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch;
  border: 0; padding: 0; background: none; cursor: pointer; min-width: 0;
  --fill: var(--bar);
}
.bar-n { font-size: 12px; color: var(--slate); text-align: center; line-height: 1.2; padding-bottom: 3px; }
.bar-fill {
  display: block;
  height: calc(var(--h) * (100% - 44px));
  min-height: 2px;
  background: var(--fill);
  border-radius: 2px 2px 0 0;
  transform-origin: bottom;
}
.bar-x { font-size: var(--s-1); text-align: center; border-top: 1px solid var(--rule); padding-top: 4px; line-height: 1.3; white-space: nowrap; }
.bar:hover { --fill: var(--bar-hover); }
.bar:hover .bar-x { color: var(--ink); }
.bar[aria-pressed="true"] { --fill: var(--carmine); }
.bar[aria-pressed="true"] .bar-x { color: var(--carmine); font-weight: 700; border-top-color: var(--carmine); }
.bar[aria-pressed="true"] .bar-n { color: var(--carmine); font-weight: 600; }
.bar.zero .bar-n, .bar.zero .bar-x { opacity: .45; }
.bar:focus-visible { outline-offset: 0; }

.bars.grow .bar-fill { animation: grow .7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i) * 35ms); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.selects { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--s-1); color: var(--slate); font-weight: 500; }
.field select {
  height: 40px; min-width: 0; max-width: 100%;
  padding: 0 34px 0 12px;
  border: 1px solid var(--rule); border-radius: 6px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 8l4.5 4.5L14.5 8' fill='none' stroke='%235C6575' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  appearance: none; -webkit-appearance: none;
  color: var(--ink); font-size: var(--s0); font-weight: 400;
  cursor: pointer;
}
.field select.active { border-color: var(--carmine); box-shadow: inset 3px 0 0 var(--carmine); }
#inst { width: 300px; }
#deg { width: 250px; }
#kind { width: 250px; }
.check-box { height: 40px; }
#reset { height: 40px; margin-left: auto; }

/* ---------------------------------------------------------------- results */
.results { padding: 18px 0 40px; outline: none; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; }
.count { font: 600 var(--s1)/1.3 var(--sans); margin: 0; }
.count .of { color: var(--slate); font-weight: 400; }
.field-inline { flex-direction: row; align-items: center; gap: 10px; }
.field-inline select { height: 36px; }

.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th {
  text-align: left; font-size: var(--s-1); font-weight: 600; color: var(--slate);
  padding: 10px 12px; border-bottom: 1px solid var(--ink);
}
.grid th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.grid th button:hover { color: var(--ink); }
.grid th[aria-sort] button { color: var(--ink); }
.grid th[aria-sort="ascending"] button::after { content: "▲"; font-size: 9px; }
.grid th[aria-sort="descending"] button::after { content: "▼"; font-size: 9px; }
.c-date { width: 128px; }
.c-name { width: 23%; }
.c-deg { width: 128px; }
.c-inst { width: 92px; }

.grid td { padding: 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tbody tr.open { background: var(--row-hover); box-shadow: inset 3px 0 0 var(--carmine); }
.d-main { white-space: nowrap; }
.d-sub { display: block; font-size: 12px; line-height: 1.35; margin-top: 2px; }
.d-sub.changed { color: var(--carmine); font-weight: 600; }
.d-sub.notreg { color: var(--slate); }
.pill {
  display: inline-block; font-size: 12px; line-height: 1; font-weight: 600;
  padding: 3px 6px 4px; border-radius: 4px; border: 1px solid currentColor; vertical-align: 1px;
}
.pill.upcoming { color: var(--ink); }
.name-btn {
  border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  font-weight: 600; font-size: var(--s0); line-height: 1.35;
}
.name-btn:hover { text-decoration: underline; text-underline-offset: 2px; }
.t-title {
  font: 400 var(--s0)/1.45 var(--serif);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.t-deg, .t-inst { color: var(--slate); }
mark { background: var(--carmine-tint); color: inherit; border-radius: 2px; padding: 0 1px; }

.empty { padding: 48px 0; color: var(--slate); max-width: 60ch; }
.more-wrap { display: flex; justify-content: center; padding-top: 24px; }
.more {
  border: 1px solid var(--rule); background: var(--surface); border-radius: 6px;
  padding: 10px 18px; cursor: pointer; font-weight: 600;
}
.more:hover { border-color: var(--ink); }
.more[hidden] { display: none; }

/* ---------------------------------------------------------------- footer */
.foot { border-top: 1px solid var(--rule); padding-top: 24px; padding-bottom: 48px; color: var(--slate); font-size: var(--s-1); }
.foot p { margin: 0 0 8px; max-width: 90ch; }
.foot details { margin-top: 12px; max-width: 80ch; }
.foot summary { cursor: pointer; color: var(--ink); font-weight: 600; font-size: var(--s0); }
.foot details p { margin: 10px 0 0; font-size: var(--s0); line-height: 1.55; }

/* ---------------------------------------------------------------- drawer */
.scrim { position: fixed; inset: 0; background: rgba(18, 21, 28, .42); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(680px, 100%);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transform: translateX(0);
  transition: transform .22s cubic-bezier(.2, .7, .2, 1);
}
.drawer.entering { transform: translateX(24px); }
.drawer-bar {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule);
}
.drawer-pos { flex: 1; color: var(--slate); font-size: var(--s-1); padding-left: 8px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { border-color: var(--rule); }
.icon-btn:disabled { opacity: .35; cursor: default; border-color: transparent; }
.drawer-body { overflow-y: auto; padding: 28px 32px 48px; overscroll-behavior: contain; }

.d-name { font: 600 var(--s3)/1.2 var(--serif); margin: 0 0 6px; outline: none; }
.d-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 4px; background: var(--rule-soft); color: var(--slate); }
.badge.warn { background: var(--carmine-tint); color: var(--carmine); }
.badge.ink { background: var(--ink); color: var(--surface); }

.d-title {
  font: 400 var(--s2)/1.45 var(--serif);
  margin: 0 0 6px;
  padding-left: 16px; border-left: 3px solid var(--rule);
}
.d-title2 { margin: 6px 0 0; padding-left: 19px; color: var(--slate); font: italic 400 var(--s0)/1.5 var(--serif); }

.facts { display: grid; grid-template-columns: 148px 1fr; gap: 10px 18px; margin: 24px 0 8px; }
.facts dt { color: var(--slate); font-size: var(--s-1); padding-top: 2px; }
.facts dd { margin: 0; }
.facts .sub { display: block; color: var(--slate); font-size: var(--s-1); }

.d-sec { margin-top: 32px; }
.d-sec h3 { font: 600 var(--s1)/1.3 var(--sans); margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.d-note { color: var(--slate); font-size: var(--s-1); margin: 8px 0 0; }

/* Date history: struck-out announced dates, then the date the defence took place. */
.hist { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; font-size: var(--s1); }
.hist s { color: var(--slate); text-decoration-color: var(--carmine); text-decoration-thickness: 2px; }
.hist .final { font-weight: 700; }
.hist .sep { color: var(--slate); }
.mismatch { background: var(--carmine-tint); color: var(--ink); padding: 10px 12px; border-radius: 6px; margin: 0; }

/* Notice timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 0 0 20px; }
.tl li::before { content: ""; position: absolute; left: 110px; top: 8px; bottom: 0; width: 1px; background: var(--rule); }
.tl li:last-child::before { display: none; }
.tl-date { font-size: var(--s-1); color: var(--slate); padding-top: 2px; text-align: right; padding-right: 8px; }
.tl-body { position: relative; padding-left: 14px; min-width: 0; }
.tl-body::before {
  content: ""; position: absolute; left: -4px; top: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--bar-hover);
}
.tl li.t-moved .tl-body::before, .tl li.t-correction .tl-body::before { border-color: var(--carmine); }
.tl li.t-held .tl-body::before { background: var(--ink); border-color: var(--ink); }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.src { font-size: 11px; font-weight: 700; padding: 2px 5px; border-radius: 3px; letter-spacing: .02em; }
.src-LV { background: var(--ink); color: var(--surface); }
.src-ZV { border: 1px solid var(--ink); padding: 1px 4px; }
.tl-type { font-weight: 600; }
.tl-iss { color: var(--slate); font-size: var(--s-1); }
.tl-line { margin: 4px 0 0; font-size: var(--s-1); }
.tl-line.moved { color: var(--carmine); font-weight: 600; }
.tl-com { margin: 4px 0 0; font-size: var(--s-1); color: var(--slate); }
.tl-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: var(--s-1); }
.tl-text {
  margin: 10px 0 0; padding: 12px 14px; background: var(--paper); border: 1px solid var(--rule-soft); border-radius: 6px;
  font: 400 var(--s-1)/1.6 var(--serif); white-space: pre-wrap; overflow-wrap: anywhere;
}

.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.links li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.links a { font-weight: 500; }
.links .host { color: var(--slate); font-size: var(--s-1); overflow-wrap: anywhere; }
.d-foot { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--rule); color: var(--slate); font-size: var(--s-1); display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; }
.copied { color: var(--carmine); font-weight: 600; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .ribbons { grid-template-columns: 1fr; gap: 22px; }
  #reset { margin-left: 0; }
}
@media (max-width: 720px) {
  :root { --gutter: 16px; }
  h1 { font-size: var(--s3); }
  .mast { padding-top: 22px; padding-bottom: 18px; }
  .lede { font-size: var(--s0); }
  .bars { height: 112px; }
  .bar-n { font-size: 11px; }
  .bar-x { font-size: 11px; }
  .selects { display: grid; grid-template-columns: 1fr; }
  #inst, #deg, #kind { width: 100%; }
  .grid thead { display: none; }
  .grid, .grid tbody { display: block; }
  .grid tbody tr {
    display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px;
    padding: 14px 0; border-bottom: 1px solid var(--rule-soft);
  }
  .grid td { padding: 0; border: 0; width: auto; min-width: 0; }
  .grid td.c-date { grid-column: 1; grid-row: 1; }
  .grid td.c-deg { grid-column: 2; grid-row: 1; }
  .grid td.c-inst { grid-column: 3; grid-row: 1; text-align: right; }
  .grid td.c-name { grid-column: 1 / -1; grid-row: 2; padding-top: 4px; }
  .grid td.c-title { grid-column: 1 / -1; grid-row: 3; }
  .d-main, .d-sub { display: inline; }
  .d-sub { margin-left: 6px; }
  .drawer-body { padding: 22px 16px 40px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 10px; }
  .tl li { grid-template-columns: 1fr; gap: 2px; padding-left: 20px; }
  .tl li::before { left: 4px; top: 8px; }
  .tl-date { text-align: left; padding: 0; }
  .tl-body { padding-left: 0; }
  .tl-body::before { left: -20px; top: -17px; }
}

@media (prefers-reduced-motion: reduce) {
  .bars.grow .bar-fill { animation: none; }
  .drawer { transition: none; }
}
