/* ==========================================================================
   saeedtaghavi.com
   One face throughout: B Nazanin, regular and bold. The page is a sheet of
   paper laid on a slightly lighter surface.
   ========================================================================== */

@font-face {
  font-family: 'B Nazanin';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/bnazanin.woff2') format('woff2');
}

@font-face {
  font-family: 'B Nazanin';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/bnazanin-bold.woff2') format('woff2');
}

/* --------------------------------------------------------------- tokens -- */

:root {
  --surround: #F2F3EE;   /* the desk the page rests on */
  --bg:       #E7E8E2;   /* the page itself */
  --bg-2:     #DFE1DA;
  --ink:      #141715;
  --ink-2:    #2F3430;
  --muted:    #5F655F;
  --rule:     #C4C9C1;
  --hair:     #D5D9D1;
  --accent:   #2F6157;
  --danger:   #B4402F;

  --face: 'B Nazanin', 'Nazanin', Tahoma, sans-serif;

  --measure: 34rem;
  --side: 5rem;
  --gap: 1.5rem;
  --pad: 1.75rem;
  --sheet: 56rem;

  --grain: 0.055;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surround: #191D1B;
    --bg:       #111413;
    --bg-2:     #171A18;
    --ink:      #E3E4DC;
    --ink-2:    #C2C5BD;
    --muted:    #838983;
    --rule:     #292E2B;
    --hair:     #1F2321;
    --accent:   #82B6A7;
    --danger:   #E08270;
    --grain:    0.035;
  }
}

:root[data-theme="dark"] {
  --surround: #191D1B;
  --bg:       #111413;
  --bg-2:     #171A18;
  --ink:      #E3E4DC;
  --ink-2:    #C2C5BD;
  --muted:    #838983;
  --rule:     #292E2B;
  --hair:     #1F2321;
  --accent:   #82B6A7;
  --danger:   #E08270;
  --grain:    0.035;
}

/* ---------------------------------------------------------------- base -- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--surround);
  color: var(--ink);
  font-family: var(--face);
  /* B Nazanin draws small for its point size, so everything is set up a notch. */
  font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.5rem);
  font-weight: 400;
  line-height: 2;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* The sheet: everything the reader touches sits on it. */
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--sheet);
  margin-inline: auto;
  background-color: var(--bg);
  border-inline: 1px solid var(--hair);
}

.sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sheet > * { position: relative; z-index: 1; }

@media (max-width: 58rem) {
  .sheet { border-inline: 0; }
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 1px;
}

::selection { background: var(--accent); color: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
}

.skip {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.95rem;
}
.skip:focus { inset-inline-start: 0; }

/* -------------------------------------------------------------- layout -- */

.shell {
  width: 100%;
  max-width: calc(var(--measure) + var(--side) + var(--gap));
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* The form label keeps the reading edge (right in RTL) and the text sits just
   inside it — near enough to the edge to look deliberate, far enough to keep a
   margin. --side is only as wide as a label needs. */
.grid {
  display: grid;
  grid-template-columns: var(--side) minmax(0, var(--measure));
  column-gap: var(--gap);
  align-items: start;
}

.grid > .side { padding-top: 0.75rem; }

@media (max-width: 52rem) {
  .grid { grid-template-columns: minmax(0, 1fr); row-gap: 0.5rem; }
  .grid > .side { padding-top: 0; }
}

main { flex: 1 0 auto; }

/* ------------------------------------------------------------ masthead -- */

.masthead { padding-block: 2.25rem 0; }

.masthead .bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  flex-wrap: wrap;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink);
  transition: color 180ms ease;
}
.wordmark:hover { color: var(--accent); }

.nav {
  display: flex;
  gap: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.5;
}

.nav a {
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* --------------------------------------------------------------- label -- */

.label {
  display: block;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--accent);
}

/* ---------------------------------------------------------------- home -- */

.home {
  display: flex;
  align-items: center;
  min-height: min(64vh, 32rem);
  padding-block: 2.5rem 1rem;
}

.home .verse {
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.05rem);
  line-height: 2.15;
  color: var(--ink);
}

.more {
  display: inline-block;
  margin-top: 2.5rem;
  font-size: 1.05rem;
  color: var(--accent);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 3px;
  transition: border-color 180ms ease;
}
.more:hover { border-bottom-color: var(--accent); }

/* --------------------------------------------------------------- verse -- */

/* Verse is never justified — the line breaks are the poem. */
.verse { text-align: start; }
.verse .stanza { display: block; }
.verse .stanza + .stanza { margin-top: 1.4em; }
.verse .line { display: block; }

.piece .verse {
  font-size: clamp(1.4rem, 1.15rem + 1.2vw, 1.8rem);
  line-height: 2.2;
  color: var(--ink);
}

/* --------------------------------------------------------------- prose -- */

.prose p {
  margin: 0 0 1.05em;
  color: var(--ink-2);
  text-align: justify;
  text-justify: inter-word;
  hyphens: none;
}
.prose p:last-child { margin-bottom: 0; }

.prose > p.lede { color: var(--ink); }

.prose .divider {
  display: block;
  height: 1px;
  width: 4rem;
  margin: 2rem auto;
  background: var(--rule);
}

/* ------------------------------------------------------------- section -- */

.page-title {
  font-size: clamp(1.85rem, 1.5rem + 1.5vw, 2.35rem);
  font-weight: 700;
  line-height: 1.6;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}

.section-head { padding-block: 2.75rem 0; }

/* -------------------------------------------------- table of contents -- */

.contents-group { margin-top: 2.75rem; }
.contents-group:first-of-type { margin-top: 2rem; }

.contents-group > h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.8;
  color: var(--accent);
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--hair);
}

.contents {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contents li + li { margin-top: 0.15rem; }

/* Title, dot leader, then the word that carries the link — a book's index. */
.contents a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding-block: 0.5rem;
  color: var(--ink);
  transition: color 180ms ease;
}

.contents .t {
  flex: 0 1 auto;
  font-size: 1.3rem;
  line-height: 1.8;
}

.contents .leader {
  flex: 1 1 auto;
  min-width: 1.5rem;
  align-self: center;
  border-bottom: 1px dotted var(--rule);
  transform: translateY(-0.15em);
  transition: border-color 180ms ease;
}

.contents .go {
  flex: 0 0 auto;
  font-size: 1.1rem;
  color: var(--accent);
  white-space: nowrap;
}

.contents a:hover { color: var(--accent); }
.contents a:hover .leader { border-bottom-color: var(--accent); }

.contents .empty,
.empty { padding-block: 1.5rem; color: var(--muted); }

@media (max-width: 30rem) {
  .contents .t { font-size: 1.05rem; }
  .contents .go { font-size: 0.95rem; }
}

/* --------------------------------------------------------------- piece -- */

.piece { padding-block: 2.75rem 0; }

.piece-title {
  font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.5rem);
  font-weight: 700;
  line-height: 1.6;
  margin: 0 0 1.75rem;
  color: var(--ink);
  text-wrap: balance;
}

/* The year the piece was written, sitting where the text runs out. */
.piece .year {
  margin: 1.5rem 0 0;
  text-align: end;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

/* --------------------------------------------------------------- pager -- */

.pager {
  margin-top: 3.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hair);
  display: flex;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
}

.pager a {
  display: grid;
  gap: 0.05rem;
  max-width: 15rem;
  color: var(--ink-2);
  line-height: 1.7;
  transition: color 180ms ease;
}
.pager a:hover { color: var(--accent); }

.pager .dir { font-size: 0.95rem; color: var(--muted); }
.pager .name { font-size: 1.15rem; font-weight: 700; }
.pager .next { text-align: end; }

/* --------------------------------------------------------------- about -- */

.contact {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 1.15rem;
  line-height: 2;
}

.contact a {
  color: var(--accent);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: border-color 180ms ease;
}
.contact a:hover { border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- foot -- */

.foot { flex: 0 0 auto; padding-block: 3.25rem 2.25rem; }

.foot .inner {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  flex-wrap: wrap;
  padding-top: 1.15rem;
  border-top: 1px solid var(--hair);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--muted);
}

.foot a { transition: color 180ms ease; }
.foot a:hover { color: var(--accent); }

/* ----------------------------------------------------------------- 404 -- */

.notfound { padding-block: 4rem 2rem; }

/* ==========================================================================
   Admin
   ========================================================================== */

.admin .shell { max-width: 52rem; }
.admin { line-height: 1.8; }

.admin h1 { font-size: 1.75rem; line-height: 1.6; margin: 0; font-weight: 700; }

.admin-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: 2.25rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.admin-bar .tools { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }

.admin main { padding-bottom: 3rem; }

.btn {
  display: inline-block;
  font-family: var(--face);
  font-size: 1.05rem;
  line-height: 1.6;
  padding: 0.35rem 1rem;
  color: var(--bg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 0;
  cursor: pointer;
  transition: opacity 180ms ease;
}
.btn:hover { opacity: 0.86; }

.btn.ghost {
  color: var(--ink-2);
  background: transparent;
  border-color: var(--rule);
}
.btn.ghost:hover { color: var(--accent); border-color: var(--accent); }

.btn.danger { color: var(--danger); background: transparent; border-color: var(--rule); }
.btn.danger:hover { color: var(--bg); background: var(--danger); border-color: var(--danger); }

.btn.tiny { font-size: 0.95rem; padding: 0.15rem 0.6rem; }

.btn:disabled,
.btn:disabled:hover {
  opacity: 0.32;
  cursor: default;
  color: var(--muted);
  background: transparent;
  border-color: var(--hair);
}

.field { display: grid; gap: 0.3rem; margin-bottom: 1.15rem; }

.field > label { font-size: 1rem; color: var(--muted); }
.field .hint { font-size: 0.95rem; color: var(--muted); line-height: 1.7; }

.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field select,
.field textarea {
  font-family: var(--face);
  font-size: 1.1rem;
  line-height: 1.9;
  padding: 0.4rem 0.7rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 0;
  width: 100%;
}

.field textarea {
  font-size: 1.2rem;
  line-height: 2.1;
  min-height: 22rem;
  resize: vertical;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.row { display: flex; gap: 1.15rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; }

.check { display: flex; align-items: center; gap: 0.5rem; font-size: 1.05rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.admin-list { list-style: none; margin: 1.75rem 0 0; padding: 0; }

.admin-list > li {
  display: flex;
  align-items: center;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
  padding-block: 0.8rem;
  border-top: 1px solid var(--hair);
}
.admin-list > li:last-child { border-bottom: 1px solid var(--hair); }

.admin-list .who { flex: 1 1 14rem; min-width: 0; }
.admin-list .who b { font-weight: 700; font-size: 1.15rem; }
.admin-list .who .meta { font-size: 0.95rem; color: var(--muted); }
.admin-list .acts { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.admin-list form { display: inline; }

.admin-list .inline-edit {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex: 1 1 14rem;
}
.admin-list .inline-edit input {
  font-family: var(--face);
  font-size: 1.05rem;
  padding: 0.25rem 0.6rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--rule);
  border-radius: 0;
  min-width: 0;
  flex: 1 1 auto;
}

.pill {
  font-size: 0.9rem;
  padding: 0 0.45rem;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.notice {
  margin: 1.25rem 0 0;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 1.05rem;
}

.notice.bad { border-color: var(--danger); color: var(--danger); }

.login { max-width: 22rem; margin: 4.5rem auto; }
