/* ==========================================================================
   NxSAM documentation portal
   Brand values are taken verbatim from brand/palette.yml, which is itself read off
   the live eSec Forte theme. Do not "improve" them here; change the master.
   Derived neutrals are OKLCH tinted toward the brand blue so no grey reads as dead.

   Light, deliberately: a support engineer or a customer's analyst looks this up on a
   corporate laptop mid-workday, and every poster on the page is a screenshot of a
   light application. A dark shell would fight both the screenshots and the manual.
   ========================================================================== */

:root {
  --primary:      #1b599d;
  --primary-deep: #002157;
  --interactive:  #4178be;

  --heading:   #333333;
  --secondary: #5b5b5b;
  --body:      #4a4a4a;

  --bg:      #ffffff;
  --surface: oklch(98.6% 0.003 250);
  --rail:    oklch(97.2% 0.005 250);
  --border:  oklch(92.5% 0.006 250);
  --border-strong: oklch(86% 0.01 250);

  --focus: oklch(58% 0.13 250);

  --step: 0.5rem;
  --shell: 76rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: "Montserrat", "Source Sans Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  font-weight: 400;
}

h1, h2, h3 { color: var(--heading); font-weight: 700; line-height: 1.2; margin: 0; }
a { color: var(--interactive); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

img { max-width: 100%; height: auto; display: block; }

/* --- top bar -------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 60px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.bar__home {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--heading);
}
.bar__home span {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--secondary);
}
.bar__home img { height: 26px; width: auto; }

.bar__nav { display: flex; gap: 1.75rem; }
.bar__nav a {
  color: var(--body);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 180ms var(--ease), border-color 180ms var(--ease);
}
.bar__nav a:hover { color: var(--primary); border-bottom-color: var(--interactive); }

/* --- hero ---------------------------------------------------------------- */

.hero {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 4.5rem 1.5rem 3rem;
}
.hero h1 { font-size: 2.4rem; letter-spacing: -0.02em; max-width: 26ch; }
.hero p {
  margin: 1.1rem 0 0;
  font-size: 1.05rem;
  max-width: 62ch;
  color: var(--secondary);
  font-weight: 300;
}
.hero__acts { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg);
  color: var(--body);
  font-size: 0.9rem;
  font-weight: 400;
  text-decoration: none;
  transition: background 170ms var(--ease), border-color 170ms var(--ease),
              color 170ms var(--ease);
}
.btn:hover { background: var(--surface); border-color: var(--interactive); color: var(--primary); }
.btn:active { background: var(--rail); }

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}
.btn--primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); color: #fff; }

/* --- split: contents rail + modules -------------------------------------- */

.split {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 84px;
  background: var(--rail);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.1rem 0.35rem 1.1rem 1.1rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}
.toc__t {
  margin: 0 0 0.7rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.toc a {
  display: block;
  padding: 0.28rem 0;
  font-size: 0.83rem;
  color: var(--body);
  text-decoration: none;
  transition: color 150ms var(--ease);
}
.toc a:hover { color: var(--primary); }
.toc__n {
  font-size: 0.68rem;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  padding-right: 0.6rem;
}

/* --- module sections ----------------------------------------------------- */

.mods { display: flex; flex-direction: column; gap: 3.25rem; }

.mod { scroll-margin-top: 84px; }

.mod__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.9rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.mod__head h2 { font-size: 1.3rem; letter-spacing: -0.01em; }
.mod__meta {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
}
.mod__head .mod__links { margin-left: auto; }

.mod__links {
  display: inline-flex;
  gap: 1.1rem;
  align-items: baseline;
}

.readlink {
  font-size: 0.88rem;
  color: var(--interactive);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 160ms var(--ease), color 160ms var(--ease);
}
.readlink:hover { color: var(--primary); border-bottom-color: currentColor; }

.mod__body { display: flex; flex-direction: column; gap: 1.5rem; }
.mod__body--2, .mod__body--3 { gap: 1.25rem; }

/* A module with no video gets prose treatment, not an empty video slot. */
.mod--text .mod__head { border-bottom-style: dashed; }
.mod--text .mod__body { padding-bottom: 0.25rem; }

/* --- video tile ---------------------------------------------------------- */

.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  position: relative;
  transition: border-color 190ms var(--ease), box-shadow 190ms var(--ease),
              transform 190ms var(--ease);
}
.tile:hover {
  border-color: var(--interactive);
  box-shadow: 0 6px 20px -8px oklch(40% 0.06 250 / 0.28);
  transform: translateY(-2px);
}

.tile__shot {
  width: 100%;
  aspect-ratio: 1280 / 438;   /* make_posters.py crops the caption band per frame */
  object-fit: cover;
  object-position: top left;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tile__text {
  display: block;
  padding: 0.9rem 1.05rem 1rem;
  padding-right: 5rem;
}
.tile__text strong {
  display: block;
  color: var(--heading);
  font-size: 1rem;
  font-weight: 700;
}
.tile__text em {
  display: block;
  margin-top: 0.2rem;
  font-style: normal;
  font-size: 0.87rem;
  color: var(--secondary);
  font-weight: 300;
}

.tile__dur {
  position: absolute;
  right: 1.05rem;
  bottom: 1rem;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.45rem;
}

/* --- breadcrumb --------------------------------------------------------- */

.crumb {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0;
  font-size: 0.82rem;
  color: var(--secondary);
  display: flex;
  gap: 0.5rem;
}
.crumb a { text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* --- watch page --------------------------------------------------------- */

.watch {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 19rem;
  gap: 2.25rem;
  align-items: start;
}

.watch video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--primary-deep);
  border-radius: 6px;
  display: block;
}

.watch__head { margin-top: 1.5rem; }
.watch__head h1 { font-size: 1.6rem; letter-spacing: -0.015em; }
.watch__head p {
  margin: 0.45rem 0 0;
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 300;
  max-width: 68ch;
}

.watch__acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* --- chapters ----------------------------------------------------------- */

.chaps {
  position: sticky;
  top: 84px;
  background: var(--rail);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.chaps__t {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--secondary);
}
.chaps__t span { font-variant-numeric: tabular-nums; letter-spacing: 0; }

.ch {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  max-height: min(30rem, calc(100vh - 12rem));
  overflow-y: auto;
}
.ch button {
  display: flex;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--body);
  cursor: pointer;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.ch button:hover { background: var(--bg); color: var(--primary); }
.ch__t {
  font-variant-numeric: tabular-nums;
  color: var(--secondary);
  font-size: 0.78rem;
  padding-top: 0.08rem;
  min-width: 2.9rem;
}
.ch__l { flex: 1; }

/* Current chapter reads through weight and ground, never a coloured side rule. */
.ch .is-now button { background: var(--bg); color: var(--primary); font-weight: 700; }
.ch .is-now .ch__t { color: var(--interactive); }

/* --- footer ------------------------------------------------------------- */

.foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 1.5rem;
}
.foot p {
  max-width: var(--shell);
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--secondary);
}

/* --- responsive: structural, not fluid type ----------------------------- */

@media (max-width: 62rem) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .toc { position: static; max-height: none; }
  .toc ol { columns: 2; column-gap: 1.5rem; }
  .watch { grid-template-columns: minmax(0, 1fr); }
  .chaps { position: static; }
}

@media (max-width: 40rem) {
  .bar { height: auto; padding: 0.75rem 1rem; flex-wrap: wrap; gap: 0.6rem 1rem; }
  .bar__nav { gap: 1.1rem; }
  .hero { padding: 2.5rem 1rem 2rem; }
  .hero h1 { font-size: 1.8rem; }
  .split, .watch { padding-left: 1rem; padding-right: 1rem; }
  .toc ol { columns: 1; }
  .mod__head .mod__links { margin-left: 0; }
  .tile__text { padding-right: 1.05rem; }
  .tile__dur { position: static; display: inline-block; margin: 0 1.05rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
  .tile:hover { transform: none; }
}
