/* ==================== FILE HEADER ====================
 * ID:        WEB-CSS-001
 * NAME:      style
 * KIND:      web
 * PURPOSE:   How the page looks: colours, type, spacing, light and dark appearance, print layout.
 * INPUTS:    The class names used in index.html and created by app.js.
 * OUTPUTS:   Appearance only. No calculation, no data.
 * CALLS:     none
 * DEPENDS:   No outside fonts or files. Uses the fonts already installed on the computer.
 * VERSION:   0.8.0
 * STATUS:    working
 * TEST:      Look at the page (python run.py --serve) in light and dark mode, and print preview.
 * IF-BROKEN: If something looks wrong, change only the named colour or size in the :root block at the top.
 *            If the whole page loses its styling, the file is missing or the server was not restarted.
 * EXPLAIN:   Every colour and size is defined once at the top as a named value (for example --critical is the
 *            signal orange used for critical-path bars). Change it there and it changes everywhere. Orange
 *            is the one strong colour on purpose: it marks what cannot slip. Fonts are the ones already on
 *            your computer, so the page works offline and loads instantly.
 *            Version 0.4: the look of the activity editing table (.editor) and its row buttons.
 *            Version 0.6: the look of the contract panel (.contract-text, .questions, chosen-date buttons).
 *            Version 0.7: the look of the Safety checks tab (.finding cards with an orange left edge).
 *            Version 0.5: the look of the Gantt connecting lines (.g-link, with its three states) and arrowheads.
 * ==================== END HEADER ==================== */

:root {
  --paper: #edf0f3;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #566474;
  --line: #cbd3db;
  --stripe: #f5f7f9;
  --bar: #6e8aa3;
  --bar-float: #c6d2dc;
  --critical: #d9411e;
  --critical-text: #a92d0e;
  --contract: #0e7c73;
  --focus: #1f5fbf;
  --link: #2b3a4a;
  --link-idle: #8493a2;
  --font: "Bahnschrift", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10161c;
    --surface: #18212a;
    --ink: #e6ebf0;
    --muted: #9aa8b5;
    --line: #2c3844;
    --stripe: #1c2630;
    --bar: #6f8fab;
    --bar-float: #2f3f4e;
    --critical: #f2683f;
    --critical-text: #ff9a78;
    --contract: #3fc2b5;
    --focus: #7fb0ff;
    --link: #b9c8d6;
    --link-idle: #6d7d8c;
  }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; margin: 18px 0 6px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.topbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; padding: 14px 20px;
          background: var(--ink); color: var(--paper); }
.topbar h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; }
.topbar-note { font-size: 0.85rem; opacity: 0.8; }

.layout { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 20px; padding: 20px; align-items: start; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; display: grid; gap: 8px; }
.panel label { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.panel select, .panel textarea, .panel input[type="file"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 8px; }
.panel textarea { font-family: var(--mono); font-size: 0.78rem; line-height: 1.45; resize: vertical; min-height: 220px; }

button { font: inherit; cursor: pointer; border-radius: 4px; padding: 9px 14px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 650; margin-top: 10px; }
button.primary:hover { filter: brightness(1.15); }
button.secondary:hover { border-color: var(--ink); }
button:disabled { opacity: 0.55; cursor: progress; }
.status { min-height: 1.4em; font-size: 0.85rem; color: var(--muted); }

.result { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; min-width: 0; }
.empty { padding: 48px 8px; color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 4px; }

.problem { border-left: 5px solid var(--critical); background: var(--stripe); padding: 14px 16px; border-radius: 4px; }
.problem h2 { color: var(--critical-text); margin-bottom: 4px; }
.problem ul { margin: 10px 0 0; padding-left: 20px; }
.problem li { margin: 3px 0; overflow-wrap: anywhere; }

.verdict-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.verdict { font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.verdict.is-late { color: var(--critical-text); }
.verdict-detail { color: var(--muted); margin-top: 4px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 18px 0 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts > div { padding: 10px 14px 10px 0; }
.facts > div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.facts dt { font-size: 0.82rem; color: var(--muted); }
.facts dd { margin: 0; font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.gantt-figure { margin: 18px 0 6px; }
.gantt { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.gantt svg { display: block; width: 100%; min-width: 760px; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.swatch { display: inline-block; width: 18px; height: 9px; margin-right: 6px; border-radius: 2px; vertical-align: middle; }
.swatch-critical { background: var(--critical); }
.swatch-normal { background: var(--bar); }
.swatch-float { background: var(--bar-float); border: 1px dashed var(--bar); height: 9px; }
.swatch-contract { background: var(--contract); width: 3px; margin-right: 9px; height: 13px; }

/* the chart itself (drawn by app.js) */
.g-stripe { fill: var(--stripe); }
.g-grid { stroke: var(--line); stroke-width: 1; }
.g-axis-text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.g-label { fill: var(--ink); font-size: 12px; font-family: var(--font); }
.g-label-critical { font-weight: 650; }
.g-bar { fill: var(--bar); }
.g-bar-critical { fill: var(--critical); }
.g-float { fill: var(--bar-float); stroke: var(--bar); stroke-width: 1; stroke-dasharray: 3 2; }
.g-contract { stroke: var(--contract); stroke-width: 2; stroke-dasharray: 6 4; }
.g-contract-text { fill: var(--contract); font-size: 12px; font-weight: 650; font-family: var(--font); }

.tabs { display: flex; gap: 4px; margin-top: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 650; }
.pane { padding-top: 14px; }
.pane[hidden], #done[hidden], .problem[hidden], .empty[hidden] { display: none; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td:nth-child(2) { white-space: normal; min-width: 200px; }
td.links { white-space: normal; min-width: 120px; font-size: 0.85rem; color: var(--muted); }
th { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
th.num, td.num { text-align: right; padding-right: 16px; }
tr.is-critical td:first-child { border-left: 4px solid var(--critical); padding-left: 8px; }
tr.is-critical td { font-weight: 600; }

pre { margin: 0; padding: 12px; background: var(--stripe); border: 1px solid var(--line); border-radius: 4px; overflow-x: auto; font: 0.8rem/1.5 var(--mono); }
#notes-list { margin: 0; padding-left: 20px; }

@media (max-width: 860px) { .layout { grid-template-columns: 1fr; padding: 12px; } .result { padding: 14px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .topbar, .panel, .tabs, #print-button, .empty { display: none; }
  .layout { display: block; padding: 0; }
  .result { border: 0; padding: 0; }
  .pane[hidden] { display: block; }          /* print all three details sections */
  .gantt { overflow: visible; }
  .gantt svg { min-width: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Version 0.3: calendar choices, season band, holiday marks (drawn by app.js) */
:root {
  --winter: #7fa7d6; --summer: #e0a63c; --monsoon: #3f78a8; --post: #7fb38a; --holiday: #b83280;
}
@media (prefers-color-scheme: dark) {
  :root { --winter: #5f8fc4; --summer: #c28a24; --monsoon: #2f6a9c; --post: #5f9a6c; --holiday: #e07bb5; }
}
.calendar-panel { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px 12px; margin: 14px 0 0; display: grid; gap: 6px; min-width: 0; }
.calendar-panel[hidden] { display: none; }
.calendar-panel legend { font-weight: 650; padding: 0 6px; }
.hint { font-size: 0.82rem; color: var(--muted); }
.checks { display: grid; gap: 4px; margin-top: 6px; }
label.check { display: flex; gap: 6px; align-items: flex-start; font-size: 0.85rem; color: var(--ink); margin-top: 2px; }
label.check input { margin-top: 4px; }
.compare { font-size: 0.85rem; font-weight: 600; margin-top: 6px; overflow-wrap: anywhere; }
.facts > div[hidden], .legend-calendar[hidden], .tabs button[hidden] { display: none; }
.g-season { opacity: 0.9; }
.g-season-winter { fill: var(--winter); } .g-season-summer { fill: var(--summer); }
.g-season-monsoon { fill: var(--monsoon); } .g-season-post { fill: var(--post); }
.g-season-text { fill: #fff; font-size: 9px; font-family: var(--font); pointer-events: none; }
.g-holiday { fill: var(--holiday); opacity: 0.28; }
.g-holiday-idle { opacity: 0.1; }
.swatch-winter { background: var(--winter); } .swatch-summer { background: var(--summer); }
.swatch-monsoon { background: var(--monsoon); } .swatch-post { background: var(--post); }
.swatch-holiday { background: var(--holiday); opacity: 0.5; width: 6px; height: 12px; }
.legend-calendar { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.legend-calendar .swatch { margin-right: 4px; }
#cal-list, #cal-sets, #cal-warnings, #cal-weather-list { margin: 0; padding-left: 20px; }
@media print { .calendar-panel { display: none; } }

/* Version 0.4 - the activity editing table */
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; }
.editor summary { cursor: pointer; font-weight: 650; }
.editor[open] summary { margin-bottom: 8px; }
.editor-fields { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; align-items: center; margin: 10px 0; max-width: 560px; }
.editor-fields label { font-size: 0.85rem; color: var(--muted); }
.editor input[type="text"] { font: inherit; width: 100%; min-width: 0; box-sizing: border-box; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); }
#editor-table td { white-space: normal; padding-right: 6px; vertical-align: top; }
#editor-table td:nth-child(2) { min-width: 0; }
#editor-table input.cell-id { width: 6.5em; }
#editor-table input.cell-name { min-width: 14em; }
#editor-table input.cell-days { width: 5em; }
#editor-table input.cell-preds { min-width: 11em; }
#editor-table input.cell-cal { width: 7.5em; }
.editor-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.editor-buttons button.primary { margin-top: 0; }
button.row-remove { padding: 4px 9px; font-size: 0.85rem; }
@media print { .editor { display: none; } }

/* Version 0.5 - Gantt connecting lines (Primavera style) */
.gantt-tools { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.g-link { fill: none; stroke: var(--link); stroke-width: 1.3; pointer-events: stroke; }
.g-link-idle { stroke: var(--link-idle); stroke-width: 1; stroke-dasharray: 4 3; }
.g-link-critical { stroke: var(--critical); stroke-width: 1.6; }
.g-arrow { fill: var(--link); }
.g-arrow-idle { fill: var(--link-idle); }
.g-arrow-critical { fill: var(--critical); }
.swatch-link, .swatch-link-idle, .swatch-link-crit { height: 0; border-top: 2px solid var(--link); border-radius: 0; background: none; }
.swatch-link-idle { border-top: 2px dashed var(--link-idle); }
.swatch-link-crit { border-top: 2px solid var(--critical); }

/* Version 0.6 - contract panel */
.editor select, .editor textarea.contract-text { font: inherit; width: 100%; min-width: 0; box-sizing: border-box; padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); }
.editor textarea.contract-text { font-family: var(--mono); font-size: 0.78rem; line-height: 1.45; resize: vertical; margin-top: 4px; }
#contract-dates td { white-space: normal; vertical-align: top; padding-right: 8px; }
#contract-dates td:nth-child(4) { min-width: 18em; font-size: 0.85rem; color: var(--muted); }
button.pick { padding: 3px 8px; font-size: 0.82rem; margin: 0 4px 4px 0; }
button.pick[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.questions { padding-left: 1.4em; display: grid; gap: 10px; }
.questions li { font-size: 0.9rem; }
.questions input[type="text"] { display: block; margin-top: 4px; }
#contract-facts { padding-left: 1.2em; font-size: 0.9rem; }
@media print { #contract-box { display: none; } }

/* Safety checks tab (version 0.7) */
.finding { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--critical); border-radius: 6px; padding: 10px 14px; margin: 10px 0; display: grid; gap: 4px; }
.finding h4 { margin: 0; font-size: 0.95rem; }
.finding p { margin: 0; font-size: 0.88rem; }
.finding .clash { color: var(--critical-text); font-weight: 600; }
.finding .option { padding-top: 4px; }
.finding .option button { margin-left: 6px; }

/* Cloud edition: the sign-in box (hidden on a normal computer) */
[hidden] { display: none !important; }      /* a hidden box stays hidden whatever other rules say (needed by the cloud sign-in) */
.signin { max-width: 28rem; margin: 2rem auto; }
.signin input { width: 100%; box-sizing: border-box; }
.topbar #signout-button { margin-left: auto; }
