/* Procedureus — paper cards floating on linen, lime + rust accents.
   Palette borrowed from whit.'s design tokens: lime #b6d447, rust #cf2200,
   slate ink, linen surface. Lime is a fill/underline colour, never text on
   white — text accents use the deeper, AA-safe lime-deep instead. */

:root {
  color-scheme: light dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* --- brand ------------------------------------------------------- */
  --lime:        #b6d447;
  --lime-deep:   #7f9432;  /* AA-safe lime for text on paper */
  --lime-tint:   rgba(182, 212, 71, 0.22);
  --lime-tint-strong: rgba(182, 212, 71, 0.4);
  --rust:        #cf2200;
  --rust-dark:   #851600;

  /* --- surfaces ------------------------------------------------------ */
  --bg:          #f4f2e9;   /* linen */
  --surface:     #ffffff;   /* paper */
  --surface-raised: #ffffff;
  --border:      rgba(28, 31, 33, 0.12);
  --border-soft: rgba(28, 31, 33, 0.07);
  --text:        #1c1f21;
  --text-muted:  #55585a;
  --text-faint:  #83868a;

  --sidebar-bg:  #ffffff;

  --texture:         url("../images/texture.jpg");
  --texture-opacity: 1;

  --accent:        var(--lime-deep);   /* text-safe accent: links, hover text */
  --accent-strong: var(--rust);        /* secondary accent: hover / attention */
  --accent-fill:   var(--lime);        /* fills that sit under dark text */
  --accent-tint:       var(--lime-tint);
  --accent-tint-strong: var(--lime-tint-strong);

  --shadow-card:
    0 1px 2px rgba(28, 31, 33, 0.05),
    0 8px 24px rgba(28, 31, 33, 0.07),
    0 20px 48px rgba(28, 31, 33, 0.05);
  --shadow-lift:
    0 2px 4px rgba(28, 31, 33, 0.07),
    0 12px 28px rgba(28, 31, 33, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #16191a;
    --surface:     #24282a;
    --surface-raised: #262a2c;
    --border:      rgba(236, 233, 224, 0.14);
    --border-soft: rgba(236, 233, 224, 0.08);
    --text:        #ece9e0;
    --text-muted:  #b3b6b4;
    --text-faint:  #8b8f8d;
    --sidebar-bg:  #1c2022;

    --texture-opacity: 0.16;

    --lime-tint:        rgba(182, 212, 71, 0.16);
    --lime-tint-strong: rgba(182, 212, 71, 0.3);

    --accent:        var(--lime);        /* brighter lime reads fine on dark */
    --accent-strong: #e0400f;            /* brighter rust for dark surfaces */
    --accent-fill:   var(--lime);

    --shadow-card:
      0 1px 2px rgba(0, 0, 0, 0.35),
      0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lift:
      0 2px 4px rgba(0, 0, 0, 0.4),
      0 14px 32px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  --bg:          #16191a;
  --surface:     #24282a;
  --surface-raised: #262a2c;
  --border:      rgba(236, 233, 224, 0.14);
  --border-soft: rgba(236, 233, 224, 0.08);
  --text:        #ece9e0;
  --text-muted:  #b3b6b4;
  --text-faint:  #8b8f8d;
  --sidebar-bg:  #1c2022;

  --texture-opacity: 0.16;

  --lime-tint:        rgba(182, 212, 71, 0.16);
  --lime-tint-strong: rgba(182, 212, 71, 0.3);

  --accent:        var(--lime);
  --accent-strong: #e0400f;
  --accent-fill:   var(--lime);

  --shadow-card:
    0 1px 2px rgba(0, 0, 0, 0.35),
    0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lift:
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 14px 32px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg:          #f4f2e9;
  --surface:     #ffffff;
  --surface-raised: #ffffff;
  --border:      rgba(28, 31, 33, 0.12);
  --border-soft: rgba(28, 31, 33, 0.07);
  --text:        #1c1f21;
  --text-muted:  #55585a;
  --text-faint:  #83868a;
  --sidebar-bg:  #ffffff;

  --texture-opacity: 1;

  --lime-tint:        rgba(182, 212, 71, 0.22);
  --lime-tint-strong: rgba(182, 212, 71, 0.4);

  --accent:        var(--lime-deep);
  --accent-strong: var(--rust);
  --accent-fill:   var(--lime);

  --shadow-card:
    0 1px 2px rgba(28, 31, 33, 0.05),
    0 8px 24px rgba(28, 31, 33, 0.07),
    0 20px 48px rgba(28, 31, 33, 0.05);
  --shadow-lift:
    0 2px 4px rgba(28, 31, 33, 0.07),
    0 12px 28px rgba(28, 31, 33, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  position: relative;
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Linen tile, fixed behind everything so scroll never reveals a seam.
   Dimmed in dark mode rather than removed, to keep the warmth. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--texture) repeat;
  opacity: var(--texture-opacity);
  pointer-events: none;
}

a { color: var(--accent); text-decoration-color: var(--border); }
a:hover { color: var(--accent-strong); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 2px;
}

img { max-width: 100%; height: auto; }
pre, code { white-space: pre-wrap; word-break: break-word; }

/* Lime gradient underline, sitting behind the text -- the signature mark. */
.mark {
  background: linear-gradient(transparent 62%, var(--lime) 62%, var(--lime) 92%, transparent 92%);
  padding-inline: 0.06em;
  border-radius: 0.625em;
}

/* ---------------------------------------------------------------- shell */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  flex: 0 0 240px;
  width: 240px;
  background: var(--sidebar-bg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
  padding: .3rem .5rem 1.25rem;
}

.brand:hover { color: var(--text); }
.brand-mark { display: block; }

.sidenav {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.sidenav-link {
  display: block;
  padding: .5rem .75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .92rem;
  transition: background-color 130ms ease, color 130ms ease;
}

.sidenav-link:hover { color: var(--text); background: var(--border-soft); }

.sidenav-link.is-current {
  color: var(--text);
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--lime);
  font-weight: 600;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 3rem 1.5rem 4rem;
}

.doc {
  max-width: 740px;
  margin: 0 auto;
}

/* ------------------------------------------------------------ top bar (narrow) */

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    flex: none;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
  }
  .brand { padding: .3rem .25rem; }
  .sidenav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .35rem;
  }
  .content { padding: 2rem 1.1rem 3rem; }
}

/* ------------------------------------------------------------------- text */

.doc-title {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 .6rem;
}

.doc-body h1, .doc-body h2, .doc-body h3 { font-weight: 650; letter-spacing: -0.005em; }
.doc-body { margin-top: 1.5rem; }

/* Procedure description: an intro lede that belongs to the title/meta block,
   not a step. Sits tight under the meta row, with a rule and clear air
   before the first step card. */
.doc-body > .description {
  margin: -0.6rem 0 0;
  padding: 0 0 1.5rem;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-soft);
}

.doc-body > .description + section.step,
.doc-body > .description ~ section.step:first-of-type {
  margin-top: 1.8rem;
}
.doc-lead { color: var(--text-muted); font-size: 1.05rem; }

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: .5rem;
}

.doc-updated { color: var(--text-faint); }

.chip {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.6;
}

.chip.chip-steps {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.chip.is-active {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--lime);
  color: var(--text);
  font-weight: 600;
}

/* ------------------------------------------------------------------ home */

.home-hero {
  display: flex;
  align-items: baseline;
  gap: .65rem;
  flex-wrap: wrap;
}

.home-hero .brand-mark-lg { font-size: 2.4rem; line-height: 1; }

.home-summary { color: var(--text-muted); margin-top: .35rem; }

.home-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .9rem;
  margin-top: 2rem;
}

@media (max-width: 560px) {
  .home-cards { grid-template-columns: 1fr; }
}

.home-card {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  transition: box-shadow 140ms ease, transform 140ms ease;
}

.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}

.home-card-title { font-weight: 650; font-size: 1.05rem; }
.home-card-title::after {
  content: "\2192";
  margin-left: .4em;
  display: inline-block;
  transition: transform 130ms ease;
}
.home-card:hover .home-card-title::after { transform: translateX(3px); }
.home-card-sub { color: var(--text-muted); font-size: .88rem; }

/* --------------------------------------------------------------- step ui */

.progress-bar-track {
  position: sticky;
  top: 0;
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  z-index: 5;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--lime);
  transition: width .2s ease;
}

.progress-header {
  position: sticky;
  top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 0;
  margin-bottom: .5rem;
  background: var(--bg);
  font-size: .85rem;
  color: var(--text-muted);
  z-index: 5;
}

.progress-header-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.step-hint {
  color: var(--text-muted);
  opacity: .65;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .step-hint {
    display: none;
  }
}

.reset-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--rust);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 130ms ease;
}

.reset-btn:hover { color: var(--rust-dark); }

@media (prefers-color-scheme: dark) {
  .reset-btn { color: var(--accent-strong); }
  .reset-btn:hover { color: #ff5c33; }
}
:root[data-theme="dark"] .reset-btn { color: var(--accent-strong); }
:root[data-theme="dark"] .reset-btn:hover { color: #ff5c33; }

section.step {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: .9rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: opacity .15s ease, box-shadow .15s ease;
}

section.step.is-current {
  border-left: 3px solid var(--lime);
}

section.step.is-done {
  opacity: .6;
  box-shadow: none;
}

.step-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  cursor: pointer;
}

.step-badge {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
}

section.step.is-done .step-badge {
  background: var(--lime);
  border-color: var(--lime);
  color: var(--text);
}

.step-checkbox {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--lime);
  cursor: pointer;
}

.step-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

section.step.is-done .step-header h3 {
  color: var(--text-muted);
}

.step-body { margin-top: .8rem; }
.step-body.is-collapsed { display: none; }

/* ---------------------------------------------------------- attachments */

.attachments h4 { font-size: .85rem; color: var(--text-muted); margin-bottom: .3rem; }
.attachments ul { padding-left: 1.2rem; margin: 0; }
.attachments img.attachment-thumb { display: block; margin-top: .3rem; border-radius: 6px; max-width: 260px; }
.embed-fallback { font-style: italic; color: var(--text-muted); }

/* --------------------------------------------------------------- toolbar */

.section-count { color: var(--text-muted); margin-top: -.4rem; font-size: .9rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin: 1.4rem 0 .8rem;
}

.search-input {
  flex: 1 1 220px;
  padding: .5rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
}

.search-input:focus { outline: 2px solid var(--lime); border-color: var(--lime-deep); }

.sort-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  background: var(--surface);
}

.sort-btn {
  border: none;
  background: none;
  padding: .4rem .7rem;
  border-radius: 6px;
  font: inherit;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.sort-btn.is-active {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--lime);
  color: var(--text);
  font-weight: 600;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1.1rem;
}

.tag-chips .chip {
  cursor: pointer;
  border: 1px solid transparent;
}

.tag-chips .chip[hidden] { display: none; }
.tag-chips[hidden] { display: none; }

/* Per-row tag chips are buttons: click filters by that tag. */
.row-tags .chip {
  border: none;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  transition: box-shadow 130ms ease;
}
.row-tags .chip:hover { box-shadow: inset 0 0 0 1.5px var(--lime); }

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  user-select: none;
}

.toggle-chip.is-active {
  color: var(--text);
  border-color: var(--lime);
  background: transparent;
}

.toggle-chip input { accent-color: var(--lime); cursor: pointer; }

/* --------------------------------------------------------- task schedule */

.task-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1rem 0;
}

tr.task-row[hidden] { display: none; }

/* ------------------------------------------------------------------ rows */

.row-list {
  list-style: none;
  margin: 0;
  padding: .2rem .1rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border-radius: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.row:last-child { border-bottom: none; }

.row[hidden] { display: none; }

.row-title {
  font-weight: 550;
  text-decoration: none;
  color: var(--text);
  flex: 1 1 220px;
}

.row-title:hover { color: var(--accent-strong); }

.row-tags { display: flex; flex-wrap: wrap; gap: .3rem; }

.row-updated {
  color: var(--text-faint);
  font-size: .82rem;
  margin-left: auto;
  white-space: nowrap;
}

.empty-state {
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

/* ------------------------------------------------------------------ misc */

table.task-schedule {
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
  display: block;
  margin-top: 1.2rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border-radius: 12px;
}

table.task-schedule th, table.task-schedule td {
  border-bottom: 1px solid var(--border-soft);
  padding: .55rem .7rem;
  text-align: left;
  font-size: .92rem;
}

table.task-schedule th {
  background: var(--lime-tint);
  font-weight: 650;
  color: var(--text);
}

.page-list { padding-left: 1.2rem; }

/* -------------------------------------------------------------- calendar */

.feed-list { list-style: none; margin: 1.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.feed-card {
  border-radius: 12px;
  padding: 1.1rem 1.3rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.feed-card h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.feed-card a { display: block; font-size: .9rem; margin-top: .2rem; word-break: break-all; }
.feed-hint { color: var(--text-muted); font-size: .88rem; margin-top: 1.5rem; }

/* -------------------------------------------------------------- not found */

.not-found {
  padding: 4rem 0;
}

.not-found .doc-title { font-size: 2.2rem; }

.not-found-back {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  margin-top: 1rem;
  font-weight: 600;
}
