/*
 * Copyright (c) 2026 by Gabriele Proietti Mattia <pm.gabriele@gmail.com>.
 *
 * All Rights Reserved.
 */

/*
 * The stylesheet of Part 3 of W2: the cooking session: the schedule, the session in progress, the end,
 * and the web page of the session (Programma, InCorso, Fine, WebSessione). It is linked after kit.css,
 * whose tokens and pieces it uses, and only adds to them. Nothing here is written in a style
 * attribute: a position or a width that depends on the data is a custom property that session.js sets
 * on the node (--at, --from, --span, --row, --rows, --pct), with the default below.
 */

/* ------------------------------------------------------------------------ the page */

.session-page {
  --at: 0;
  --from: 0;
  --span: 0;
  --row: 0;
  --rows: 1;
  --pct: 0;
}

.session-go { width: 100%; min-height: 48px; }

.session-small { min-height: 44px; padding: 0 var(--space-3); font-size: var(--fs-body-sm); }

/* the elapsed time and the thin bar of how far the session is, under the arrow of the page */
.session-page--run .subpage__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-3);
  row-gap: var(--space-2);
}

.session-page--run .subpage__head {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.session-elapsed {
  font-family: var(--font-mono);
  font-size: var(--fs-body-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.session-progress {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}

.session-progress__fill {
  width: calc(var(--pct) * 1%);
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}

/* ------------------------------------------------------------------------ Programma */

.session-summary { display: flex; flex-direction: column; gap: 2px; }
.session-summary__sub { color: var(--text-muted); }
.session-summary__finish { margin-top: var(--space-2); }

.session-chart {
  gap: var(--space-3);
  padding: 14px;
  border-color: var(--accent-soft-border);
  box-shadow: var(--shadow-md);
}

.session-axis {
  position: relative;
  height: 16px;
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.session-axis__tick {
  position: absolute;
  top: 0;
  left: calc(var(--at) * 1%);
  white-space: nowrap;
}

.session-lane { display: flex; flex-direction: column; gap: var(--space-1); }

.session-lane__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.session-lane__name { font-weight: var(--fw-medium); }
.session-lane__where { font-size: var(--fs-body-sm); color: var(--text-muted); }

.session-track {
  position: relative;
  height: calc(var(--rows) * 22px + 8px);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
}

.session-track__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--at) * 1%);
  width: 1px;
  background: var(--border-strong);
}

.session-bar {
  position: absolute;
  top: calc(4px + var(--row) * 22px);
  left: calc(var(--from) * 1%);
  width: calc(var(--span) * 1%);
  min-width: 3px;
  box-sizing: border-box;
  border-radius: var(--radius-xs);
}

.session-bar--hands { height: 14px; background: var(--accent); }
.session-bar--alone { height: 8px; margin-top: 3px; background: var(--accent-soft); border: 1px solid var(--accent-soft-border); }

.session-legend { display: flex; align-items: center; gap: var(--space-5); font-size: var(--fs-caption); }
.session-legend__item { display: inline-flex; align-items: center; gap: var(--space-2); }

.session-swatch { display: inline-block; width: 24px; border-radius: var(--radius-xs); box-sizing: border-box; }
.session-swatch--hands { height: 14px; background: var(--accent); }
.session-swatch--alone { height: 8px; background: var(--accent-soft); border: 1px solid var(--accent-soft-border); }

.session-kitchen { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------------ InCorso */

.session-run { display: flex; flex-direction: column; gap: var(--space-5); }

.session-now {
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-color: var(--accent-soft-border);
  box-shadow: var(--shadow-md);
}

.session-now__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--accent);
}

.session-now__title {
  margin: 0;
  font-size: var(--fs-h1);
  line-height: var(--lh-heading);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
}

.session-now__detail { margin: 0; font-size: var(--fs-body-lg); color: var(--text-muted); }

.session-big { width: 100%; min-height: 64px; font-size: var(--fs-body-lg); font-weight: var(--fw-semibold); }

.session-timers, .session-next, .session-tracks { display: flex; flex-direction: column; gap: var(--space-2); }

.session-timer-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.session-timer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: var(--space-2) var(--space-3);
}

.session-timer + .session-timer { border-top: 1px solid var(--border); }

.session-timer__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-timer__label { font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-timer__where { font-size: var(--fs-body-sm); color: var(--text-muted); }

.session-timer__left {
  font-family: var(--font-mono);
  font-size: var(--fs-h3);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
}

.session-timer--ring .session-timer__left { color: var(--warn); }
.session-timer__actions { flex-basis: 100%; display: flex; gap: var(--space-2); }

.session-next__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.session-next__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-next__when { flex: none; font-size: var(--fs-body-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.session-bell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin: 0;
  min-height: 40px;
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
}

/* ------------------------------------------------------------------- the tracks of the session */

.session-tracks__head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); }

.session-tracks__card { padding: var(--space-4) var(--space-5); gap: var(--space-2); }

.session-tracks__rows { position: relative; display: flex; flex-direction: column; gap: var(--space-2); }

.session-tracks__lane { display: flex; align-items: center; gap: var(--space-4); }
.session-tracks__name { flex: none; width: 150px; font-size: var(--fs-body-sm); }

.session-track--flat { flex: 1; min-width: 0; height: 32px; }
.session-bar--flat { top: calc(4px + var(--row) * 14px); height: 12px; margin-top: 0; }

.session-cursor {
  position: absolute;
  top: calc(-1 * var(--space-1));
  bottom: calc(-1 * var(--space-1));
  left: calc(166px + (100% - 166px) * var(--at) / 100);
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  pointer-events: none;
}

.session-tracks__axis { display: flex; flex-direction: column; gap: var(--space-1); padding-left: 166px; }
.session-axis--flat { height: 20px; }
.session-axis__tick--last { transform: translateX(-100%); }

.session-tracks__now { position: relative; height: 18px; font-family: var(--font-mono); font-size: var(--fs-caption); }

.session-tracks__nowlabel {
  position: absolute;
  left: calc(var(--at) * 1%);
  transform: translateX(-50%);
  font-weight: var(--fw-medium);
}

/* ------------------------------------------------------------------------ Fine */

.session-line { gap: 0; padding: var(--space-3) var(--space-3) var(--space-1); }

.session-line__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.session-line__name { font-weight: var(--fw-semibold); }
.session-line__total { font-size: var(--fs-body-sm); color: var(--text-muted); }

.session-place {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 60px;
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.session-place + .session-place { margin-top: 0; }

.session-place__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.session-place__name { display: inline-flex; align-items: center; gap: var(--space-1); font-weight: var(--fw-medium); }
.session-place--fridge .session-place__name { color: var(--accent); }
.session-place--freezer .session-place__name { color: var(--cold); }

.session-totals { font-size: var(--fs-body-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.session-pantry { display: flex; flex-direction: column; gap: var(--space-2); }

.session-takes { gap: 0; margin: 0; padding: 0; list-style: none; }

.session-take { display: flex; align-items: center; gap: var(--space-2); min-height: 56px; padding: 6px var(--space-2) 6px var(--space-3); }
.session-take + .session-take { border-top: 1px solid var(--border); }
.session-take__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-take__name { font-weight: var(--fw-medium); }
.session-take__qty { font-size: var(--fs-body-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.session-take--out .session-take__name { color: var(--text-muted); text-decoration: line-through; }

.session-skips { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; padding: var(--space-1) 0; list-style: none; }

.session-skip {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 32px;
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
}

.session-pantry__home { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--fs-body-sm); color: var(--text-muted); }

.session-done { gap: var(--space-4); border-color: var(--accent-soft-border); box-shadow: var(--shadow-md); }
.session-done__head { display: flex; align-items: center; gap: var(--space-3); }

.session-done__mark {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-circle);
  background: var(--success-soft);
  color: var(--success);
}

.session-done__text { display: flex; flex-direction: column; }
.session-done__title { font-size: var(--fs-h4); font-weight: var(--fw-semibold); }
.session-done__buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-2); }

/* ------------------------------------------------------------- WebSessione: the session alone */

/* the wide page of a session in progress has no tabs and no dock: the session is the page */
@media (min-width: 1180px) {
  #app.is-session { display: block; max-width: none; }
  #app.is-session .tabs, #app.is-session .dock { display: none; }
  #app.is-session #subpages { padding: 0; }

  .session-page--run .subpage__bar { padding-top: var(--space-3); }
  .session-page--run .subpage__body { max-width: 1200px; padding-block: var(--space-6); }
  .session-page--run .session-elapsed { font-size: var(--fs-h3); }
  .session-page--run .session-progress { height: 6px; }

  .session-page--run .session-run { gap: var(--space-7); }

  .session-page--run .session-now {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-6);
    padding: var(--space-7);
  }

  .session-page--run .session-now > :not(.session-big) { flex: 1 1 420px; min-width: 0; }
  .session-page--run .session-now__title { font-size: var(--fs-display-lg); }
  .session-page--run .session-now__detail { font-size: var(--fs-h3); }
  .session-page--run .session-now__eyebrow { font-size: var(--fs-body); }
  .session-page--run .session-big { flex: 0 1 320px; width: auto; min-height: 96px; font-size: var(--fs-h3); }

  .session-page--run .session-timer-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: var(--space-4);
    background: transparent;
    border: 0;
  }

  .session-page--run .session-timer {
    padding: var(--space-5) var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .session-page--run .session-timer + .session-timer { border-top: 1px solid var(--border); }
  .session-page--run .session-timer__label { font-size: var(--fs-h4); }
  .session-page--run .session-timer__where { font-size: var(--fs-body); }
  .session-page--run .session-timer__left { font-size: var(--fs-display-lg); }
}
