/* PhD Atlas "notebook" style for the public pages: white paper, black ink, a blue pen.
   Pen-drawn sketches, torn paper slips, rubber stamps, and connectors with a moving dot.
   Animations start when an element scrolls into view (notebook.js adds .in) and are off with prefers-reduced-motion. */
:root {
  --paper: #ffffff; --ink: #0e0d0c; --soft: #6b6862; --rule: #e7e5e0; --line: #e6e6e6;
  --blue: #0b45b8; --green: #1d6b3a; --red: #a3261b; --tape: #e6e2d2bf; --tape-edge: #0000000f; --bubble: #f4f4f2;
  --font: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --page: 1120px; --margin: 24px; --u: 48px; --header-h: 72px; --text: 18px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
}
html[lang="fa"] { --font: "Vazirmatn", Tahoma, sans-serif; }
@media (max-width: 760px) { :root { --margin: 16px; --u: 36px; --text: 17px; --header-h: 64px; } }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body.nb { margin: 0; background: var(--paper); color: var(--ink); font: 400 var(--text)/1.75 var(--font); -webkit-font-smoothing: antialiased; }
.nb h1, .nb h2, .nb h3 { margin: 0; font-weight: 500; text-wrap: balance; }
.nb p, .nb ul, .nb ol { margin: 0; }
.nb [hidden] { display: none !important; }
.nb :focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 1px; }
.nb .soft { color: var(--soft); }
.nb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* links and buttons */
.nb a { color: var(--ink); }
.nb .link { text-decoration: underline 1px; text-underline-offset: 5px; text-decoration-skip-ink: none; transition: text-decoration-thickness .12s; }
@media (hover: hover) { .nb .link:hover { text-decoration-thickness: 2px; } }
.nb .btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; height: 44px; padding-inline: 18px;
  border: 1px solid var(--ink); border-radius: 2px; background: var(--ink); color: var(--paper); font: 400 16px/1 var(--font);
  text-decoration: none; white-space: nowrap; cursor: pointer; transition: transform .18s cubic-bezier(.2, 0, 0, 1); }
.nb .btn.ghost { background: var(--paper); color: var(--ink); }
.nb .btn.lg { height: 52px; padding-inline: 24px; font-size: 17px; }
.nb .btn:active { transform: translateY(1px); }
/* a light sheen runs over the main button once after load, and on hover */
.nb .btn::before { content: ""; position: absolute; top: 0; bottom: 0; left: -160%; width: 55%; pointer-events: none;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .5), transparent); transform: skew(-20deg); }
.nb .btn.ghost::before { background: linear-gradient(120deg, transparent, rgba(0, 0, 0, .08), transparent); }
.nb .btn.sheen::before { animation: nb-sheen .9s ease-out forwards; }
@keyframes nb-sheen { to { transform: translate(600%) skew(-20deg); } }

/* header: a hairline appears after the first scroll */
.nb-header { position: sticky; top: 0; z-index: 20; background: var(--paper); }
.nb-header::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 1px; background: transparent; transition: background-color .15s; }
.nb-header[data-scrolled]::after { background: var(--rule); }
.nb-bar { max-width: var(--page); height: var(--header-h); margin-inline: auto; padding-inline: var(--margin); display: flex; align-items: center; gap: 36px; position: relative; }
.nb-brand { display: inline-flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 500; line-height: 1; text-decoration: none; color: var(--ink); padding-block: 10px; }
.nb-brand svg { width: 28px; height: 28px; flex: none; }
.nb-nav { display: flex; gap: 26px; }
.nb-nav a, .nb-end .plain { color: var(--soft); text-decoration: none; font-size: 16px; min-height: 44px; display: inline-flex; align-items: center; transition: color .12s; }
@media (hover: hover) { .nb-nav a:hover, .nb-end .plain:hover { color: var(--ink); text-decoration: underline 1px; text-underline-offset: 4px; } }
.nb-end { margin-inline-start: auto; display: flex; align-items: center; gap: 22px; }
.nb-menu-btn { display: none; width: 44px; height: 44px; border: 1px solid var(--soft); border-radius: 2px; background: var(--paper); color: var(--ink); cursor: pointer; padding: 0; align-items: center; justify-content: center; }
.nb-menu-btn svg { width: 18px; height: 18px; }
.nb-sheet { position: absolute; top: 100%; inset-inline: 0; background: var(--paper); border-bottom: 1px solid var(--ink); padding: 8px var(--margin) 20px; }
.nb-sheet ul { list-style: none; padding: 0; }
.nb-sheet li + li { border-top: 1px solid var(--rule); }
.nb-sheet a { display: flex; align-items: center; min-height: 52px; font-size: 18px; text-decoration: none; }
.nb-nav a { white-space: nowrap; }
@media (max-width: 1060px) { .nb-nav, .nb-end .plain.opt { display: none; } .nb-menu-btn { display: inline-flex; } }

/* page and sections */
.nb-main { max-width: var(--page); margin-inline: auto; padding-inline: var(--margin); }
.nb-hero { min-height: calc(100svh - var(--header-h)); padding-block: calc(var(--u) * 1.4) var(--u); }
.nb-hero h1 { font-size: clamp(30px, 4.2vw, 44px); line-height: 1.45; letter-spacing: -.012em; max-width: 17em; }
.nb-hero h1 .soft { font-weight: 400; }
.nb-kicker { font: 500 13px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--soft); margin-bottom: 22px; }
html[lang="fa"] .nb-kicker { font-family: var(--font); letter-spacing: 0; }
.nb-list { list-style: none; padding: 0; margin-top: calc(var(--u) * 1.15); max-width: 23em; counter-reset: nb; }
.nb-list > li { position: relative; padding-inline-start: 2.2em; counter-increment: nb; text-wrap: pretty; }
.nb-list > li::before { content: counter(nb) "."; position: absolute; inset-inline-start: 0; color: var(--soft); font-variant-numeric: tabular-nums; }
html[lang="fa"] .nb-list > li::before { content: counter(nb, persian) "."; }
.nb-list > li + li { margin-top: calc(var(--u) * .45); }
.nb-list b { font-weight: 500; text-decoration: underline 1px; text-underline-offset: 6px; }
.nb-start { margin-top: var(--u); display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.nb-counter { margin-top: 18px; font-size: 15px; color: var(--soft); }

.nb-sec { padding-block-start: calc(var(--u) * 2.6); display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); column-gap: 72px; row-gap: calc(var(--u) * .9); align-items: start; }
.nb-sec > .wide { grid-column: 1 / -1; }
.nb-sec h2 { font-size: clamp(22px, 2.4vw, 27px); line-height: 1.45; letter-spacing: -.005em; }
.nb-sec h2 .soft { font-weight: 400; }
.nb-col > p { margin-top: calc(var(--u) * .5); max-width: 26em; text-wrap: pretty; }
.nb-obj { justify-self: start; position: relative; }
@media (max-width: 900px) { .nb-sec { grid-template-columns: minmax(0, 1fr); } }

/* sketches: hand-drawn line pictures, drawn by a pen when they scroll in */
.sketch { color: var(--ink); overflow: visible; pointer-events: none; }
.sketch .d, .sketch .dot { fill: none; stroke: currentColor; stroke-width: 1.4px; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.sketch .s { stroke-dasharray: 2 2.8; stroke-width: 1.1px; }
.sketch .h { stroke-width: .8px; opacity: .55; }
.sketch .dot { stroke-width: 3.4px; }
.sketch.blue { color: var(--blue); }
.nb-list .sketch { position: absolute; top: var(--sk-top, -12px); inset-inline-start: calc(100% + var(--sk-gap, 64px)); transform: rotate(var(--sk-rot, 0deg)); }
@media (max-width: 760px) {
  .nb-list .sketch { position: static; display: inline-block; height: 30px; width: auto; vertical-align: -8px; margin-inline-start: 8px; transform: none; }
  .nb-list .sketch .h, .nb-list .sketch .s { display: none; }
}
/* the pen: every stroke has pathLength=1, so the dash trick works for any path length */
.pen .d:not(.s), .pen .dot { stroke-dasharray: 1; stroke-dashoffset: 1; }
.pen .s, .pen .h, .pen text { opacity: 0; }
.pen.in .d:not(.s), .pen.in .dot { animation: nb-pen var(--dur, .7s) cubic-bezier(.6, .05, .3, 1) forwards; animation-delay: calc(var(--sk-delay, 0s) + var(--i, 0) * .14s); }
.pen.in .s, .pen.in .h, .pen.in text { animation: nb-ink .5s ease-out forwards; animation-delay: calc(var(--sk-delay, 0s) + .8s); }
@keyframes nb-pen { to { stroke-dashoffset: 0; } }
@keyframes nb-ink { to { opacity: 1; } }

/* words circled or underlined by the pen */
.mark { position: relative; white-space: nowrap; margin-inline: 10px; }
.mark.under { margin-inline: 0; }
.mark > svg { position: absolute; inset: -2px -9px -2px; width: calc(100% + 18px); height: calc(100% + 4px); color: var(--blue); overflow: visible; pointer-events: none; }
.mark.under > svg { inset: auto 0 -10px; height: 12px; width: 100%; }
.mark > svg path { fill: none; stroke: currentColor; stroke-width: 1.8px; stroke-linecap: round; vector-effect: non-scaling-stroke; }

/* text that rises in */
[data-rise] { opacity: 0; transform: translateY(10px); }
[data-rise].in { animation: nb-rise .7s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 90ms); }
@keyframes nb-rise { to { opacity: 1; transform: none; } }
/* headline lines slide up from behind a mask */
/* room around each line, so a pen circle on a word is not cut by the mask */
.lines .ln { display: block; overflow: hidden; padding: .32em .5em .12em; margin: -.32em -.5em -.04em; }
.lines .ln > span { display: inline-block; transform: translateY(105%); }
.lines.in .ln > span { animation: nb-line .9s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 120ms + 80ms); }
@keyframes nb-line { to { transform: none; } }

/* torn paper slip with a log of times */
.slip { position: relative; width: 440px; max-width: 100%; padding: 30px 28px 46px; transform: rotate(-1.2deg); background: var(--paper); }
.slip.r { transform: rotate(.9deg); }
.slip-edge { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--ink); overflow: visible; pointer-events: none; }
.slip-edge path { fill: none; stroke: currentColor; stroke-width: 1.3px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.slip-lbl { position: absolute; top: -12px; inset-inline-end: 40px; padding-inline: 8px; background: var(--paper); color: var(--soft); font-size: 13px; line-height: 22px; }
.slip-row { display: grid; grid-template-columns: 3.3em 1fr; gap: 2px 12px; font-size: 16px; line-height: 1.7; }
.slip-row + .slip-row { margin-top: 12px; }
.slip-row time { color: var(--soft); direction: ltr; text-align: end; font: 400 14px/1.9 var(--mono); }
.slip-row b { font-weight: 500; }
.slip-row small { display: block; color: var(--soft); font-size: 14px; }
.slip .clock { position: absolute; top: -44px; inset-inline-end: -52px; width: 80px; height: 80px; }
/* lines of a slip arrive one by one */
.slip [data-row] { opacity: 0; transform: translateY(8px) scale(.97); transform-origin: 0 50%; }
.slip.in [data-row] { animation: nb-row .45s var(--ease-out) forwards; animation-delay: calc(.35s + var(--i, 0) * .55s); }
@keyframes nb-row { to { opacity: 1; transform: none; } }

/* invoice-like rows with dotted leaders */
.ledger { list-style: none; padding: 0; width: 460px; max-width: 100%; }
.ledger li { display: flex; align-items: baseline; gap: 10px; font-size: 16px; line-height: 1.6; padding-block: 7px; }
.ledger li::after { content: ""; order: 2; flex: 1 1 auto; border-bottom: 1.5px dotted #9a9a9a; transform: translateY(-4px); min-width: 24px; }
.ledger .k { order: 1; }
.ledger .v { order: 3; color: var(--soft); font-size: 14px; white-space: nowrap; }
.ledger li.total { border-top: 1.4px solid var(--ink); margin-top: 8px; padding-top: 12px; font-weight: 500; }

/* rubber stamps */
.stamps { display: flex; flex-wrap: wrap; gap: 26px 30px; align-items: flex-start; padding-top: 8px; }
.stamp-note { width: 200px; display: flex; flex-direction: column; gap: 14px; font-size: 15px; line-height: 1.6; }
.stamp { align-self: flex-start; display: inline-block; padding: 6px 12px 5px; border: 2px solid currentColor; border-radius: 3px; box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3.5px currentColor;
  font: 600 13px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; transform: rotate(-9deg); opacity: 0; mix-blend-mode: multiply; }
html[lang="fa"] .stamp { font-family: var(--font); letter-spacing: 0; font-size: 15px; }
.stamp.ok { color: var(--green); } .stamp.check { color: var(--blue); } .stamp.no { color: var(--red); }
.in .stamp { animation: nb-thump .34s cubic-bezier(.3, 1.6, .5, 1) forwards; animation-delay: calc(.2s + var(--i, 0) * .45s); }
@keyframes nb-thump { from { opacity: 0; transform: rotate(-9deg) scale(1.45); } to { opacity: .92; transform: rotate(-9deg) scale(1); } }

/* flow: boxes joined by lines; a dot travels and lights each box in turn */
.flow { display: flex; align-items: stretch; margin-top: 8px; }
.flow-box { flex: 1 1 0; padding: 18px 18px 20px; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); background: var(--paper); }
.flow-box .k { font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
html[lang="fa"] .flow-box .k { font-family: var(--font); letter-spacing: 0; font-size: 13px; }
.flow-box h3 { font-size: 19px; margin: 8px 0 6px; }
.flow-box p { font-size: 15px; line-height: 1.65; color: var(--soft); }
.flow-link { position: relative; flex: 0 0 56px; align-self: center; height: 1px; background: var(--line); margin-inline: 8px; }
.flow-link i { position: absolute; top: -2px; left: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); opacity: 0; }
html[dir="rtl"] .flow-link i { left: auto; right: 0; }
.flow.in .flow-box { animation: nb-lit 6s linear infinite; animation-delay: calc(var(--i) * 1.5s); }
.flow.in .flow-link i { animation: nb-flow-x 6s linear infinite; animation-delay: calc(var(--i) * 1.5s + .35s); }
html[dir="rtl"] .flow.in .flow-link i { animation-name: nb-flow-x-rtl; }
@keyframes nb-lit { 0%, 100% { box-shadow: 0 0 0 1px var(--line); } 4% { box-shadow: 0 0 0 1.5px var(--ink); } 18% { box-shadow: 0 0 0 1px var(--line); } }
@keyframes nb-flow-x { 0% { opacity: 0; left: 0; } 3% { opacity: 1; } 16% { opacity: 1; left: calc(100% - 5px); } 20%, 100% { opacity: 0; left: calc(100% - 5px); } }
@keyframes nb-flow-x-rtl { 0% { opacity: 0; right: 0; } 3% { opacity: 1; } 16% { opacity: 1; right: calc(100% - 5px); } 20%, 100% { opacity: 0; right: calc(100% - 5px); } }
@media (max-width: 760px) {
  .flow { flex-direction: column; }
  .flow-link { flex: 0 0 36px; width: 1px; height: 36px; margin: 6px 0; margin-inline-start: 28px; align-self: auto; }
  .flow-link i { left: -2px !important; right: auto !important; top: 0; }
  .flow.in .flow-link i { animation-name: nb-flow-y !important; }
}
@keyframes nb-flow-y { 0% { opacity: 0; transform: translateY(0); } 3% { opacity: 1; } 16% { opacity: 1; transform: translateY(31px); } 20%, 100% { opacity: 0; transform: translateY(31px); } }

/* a phone held by tape */
.tape { position: absolute; width: 76px; height: 22px; background: var(--tape); border: 1px solid var(--tape-edge); pointer-events: none; }

/* live list of recent positions on a slip */
.recent a { display: grid; gap: 1px; text-decoration: none; padding-block: 8px; border-bottom: 1px dashed var(--line); }
.recent a:last-child { border-bottom: 0; }
.recent a span:first-child { font-size: 15px; line-height: 1.5; text-decoration: underline 1px transparent; text-underline-offset: 4px; transition: text-decoration-color .12s; }
@media (hover: hover) { .recent a:hover span:first-child { text-decoration-color: var(--ink); } }
.recent .meta { color: var(--soft); font-size: 13px; line-height: 1.5; }
.recent .hint { color: var(--soft); font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.chips a { line-height: 44px; }

/* closing line */
.nb-final { padding-block: calc(var(--u) * 3) calc(var(--u) * 2); display: flex; flex-direction: column; align-items: flex-start; gap: 26px; }
.nb-final h2 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.4; }

.nb-foot { max-width: var(--page); margin-inline: auto; padding: calc(var(--u) * 1.2) var(--margin); border-top: 1px solid var(--rule); color: var(--soft); font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.nb-foot a { color: var(--soft); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
@media (hover: hover) { .nb-foot a:hover { color: var(--ink); text-decoration: underline 1px; text-underline-offset: 4px; } }
.nb-foot .grow { flex: 1 1 auto; }

/* no motion: everything is shown at once */
@media (prefers-reduced-motion: reduce) {
  .pen .d, .pen .dot { stroke-dashoffset: 0 !important; animation: none !important; }
  .pen .s, .pen .h, .pen text, [data-rise], .slip [data-row], .stamp { opacity: 1 !important; transform: none !important; animation: none !important; }
  .stamp { transform: rotate(-9deg) !important; opacity: .92 !important; }
  .lines .ln > span { transform: none !important; animation: none !important; }
  .flow-box, .flow-link i, .nb .btn::before { animation: none !important; }
}

/* small screens: nothing wider than its column, a compact header */
body.nb { overflow-x: clip; }
.nb-obj { max-width: 100%; min-width: 0; }
.nb-brand span, .nb-end .plain { white-space: nowrap; }
@media (max-width: 900px) {
  .nb-obj { justify-self: stretch; }
  .slip, .ledger { width: 100%; }
}
@media (max-width: 760px) {
  .nb-bar { gap: 12px; }
  .nb-end { gap: 10px; }
  .nb-end #navOut { display: none; }
  .nb-end .btn { height: 40px; padding-inline: 12px; font-size: 15px; }
  .nb-brand { font-size: 19px; }
  .slip { padding: 26px 18px 40px; }
  .slip .clock { width: 56px; height: 56px; top: -34px; inset-inline-end: -6px; }
  .slip-lbl { inset-inline-end: 64px; }
  .slip-row { grid-template-columns: 3em 1fr; font-size: 15px; }
  .ledger .v { white-space: normal; text-align: end; }
  .stamp-note { width: 100%; }
}
@media (max-width: 380px) { .nb-end .btn { display: none; } }

/* chat widget (chat/chat-widget.js) in the notebook style, on these pages only */
body.nb .pa-chat { font-family: var(--font); color: var(--ink); }
body.nb .pa-fab { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); border-radius: 2px; font-weight: 500; padding: 11px 16px;
  box-shadow: 0 1px 2px #0000000a, 0 12px 32px #0000001a; animation: nb-pop .32s var(--ease-out) .9s backwards; transition: transform .22s var(--ease-out), box-shadow .22s; }
@media (hover: hover) { body.nb .pa-fab:hover { transform: translateY(-2px); box-shadow: 0 2px 4px #0000000f, 0 18px 40px #00000024; } }
body.nb .pa-panel { background: var(--paper); border: 1px solid var(--ink); border-radius: 3px; box-shadow: 0 2px 4px #0000000f, 0 18px 40px #00000024;
  animation: nb-panel .28s var(--ease-out); transform-origin: 100% 100%; }
html[dir="rtl"] body.nb .pa-panel { transform-origin: 0 100%; }
body.nb .pa-head { background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--rule); }
body.nb .pa-close { color: var(--ink); }
body.nb .pa-note { background: var(--bubble); color: var(--soft); border-bottom: 1px solid var(--rule); }
body.nb .pa-msg { border-radius: 10px; animation: nb-row .32s var(--ease-out); }
body.nb .pa-bot { background: var(--bubble); border: 0; }
body.nb .pa-user { background: var(--ink); color: var(--paper); }
body.nb .pa-msg a { color: var(--blue); }
body.nb .pa-form { border-top: 1px solid var(--rule); background: var(--paper); }
body.nb .pa-input { border: 0; border-bottom: 1.5px solid var(--ink); border-radius: 0; }
body.nb .pa-input:focus-visible { outline: none; border-bottom-width: 3px; }
body.nb .pa-send { background: var(--ink); border-radius: 2px; font-weight: 500; }
@keyframes nb-pop { from { opacity: 0; transform: scale(.6); } }
@keyframes nb-panel { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@media (prefers-reduced-motion: reduce) { body.nb .pa-fab, body.nb .pa-panel, body.nb .pa-msg { animation: none; } }
/* Persian lines are shorter: a narrower list keeps each item as tall as its sketch */
html[lang="fa"] .nb-list { max-width: 19em; }
html[lang="fa"] .nb-list > li + li { margin-top: calc(var(--u) * .6); }
