/* LCARS-inspired theme */
:root {
  --bg: #000;
  --orange: #ff9900;
  --peach: #ffcc99;
  --lavender: #cc99cc;
  --blue: #9999ff;
  --sky: #99ccff;
  --gold: #ffcc66;
  --red: #ff5555;
  --green: #66cc99;
  --dark: #1c1c33;

  /* sizing unit: 1vh on a 4:3-or-wider screen, shrinking with the width on narrower windows */
  --u: min(1vh, 0.75vw);

  --side: 15vw;    /* sidebar width */
  --frame: calc(11 * var(--u));   /* height of top/bottom elbow */
  --thick: calc(2.4 * var(--u));  /* thickness of horizontal bars */
  --gap: calc(0.6 * var(--u));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--peach);
  font-family: "Antonio", "Arial Narrow", "Helvetica Neue Condensed", sans-serif;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  overflow: hidden;
}

.c-orange   { background: var(--orange); }
.c-peach    { background: var(--peach); }
.c-lavender { background: var(--lavender); }
.c-blue     { background: var(--blue); }
.c-gold     { background: var(--gold); }
.c-red      { background: var(--red); }

.lcars {
  height: 100vh;
  height: 100dvh; /* iPad/iPhone Safari: excludes the browser toolbars */
  display: grid;
  grid-template-columns: var(--side) 1fr;
  /* frame, progress, now, next, later, frame */
  grid-template-rows: var(--frame) auto 1fr auto auto var(--frame);
  row-gap: var(--gap);
  padding: calc(2 * var(--u)) 2vw;
}

/* ---- elbows ---- */
.elbow {
  background: var(--orange);
  color: #000;
  font-size: calc(1.8 * var(--u));
  display: flex;
  justify-content: flex-end;
  padding: 0 1vw;
}
.elbow.top    { border-top-left-radius: calc(8 * var(--u)); align-items: flex-end; padding-bottom: calc(0.8 * var(--u)); }
.elbow.bottom { border-bottom-left-radius: calc(8 * var(--u)); align-items: flex-start; padding-top: calc(0.8 * var(--u)); }

.topbar, .bottombar {
  display: flex;
  gap: var(--gap);
}
.topbar    { align-items: flex-start; }
.bottombar { align-items: flex-end; }

/* inner curve where the elbow meets the horizontal bar */
.curve {
  width: 4vw;
  height: 100%;
  background: var(--orange);
  position: relative;
}
.curve::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  background: var(--bg);
}
.curve.top::after    { top: var(--thick); bottom: 0; border-top-left-radius: calc(4 * var(--u)); }
.curve.bottom::after { bottom: var(--thick); top: 0; border-bottom-left-radius: calc(4 * var(--u)); }

.bar { height: var(--thick); }
.w20 { width: 20%; }
.w10 { width: 10%; }
.cap { width: 4vw; border-radius: 0 var(--thick) var(--thick) 0; }
.grow { flex: 1; }

.title {
  flex: 1 0 auto;
  white-space: nowrap;
  text-align: right;
  font-size: calc(10 * var(--u));
  line-height: 0.85;
  color: var(--orange);
  letter-spacing: 0.05em;
  padding: 0 1vw;
}

.key {
  text-decoration: none;
  position: relative;
  height: var(--thick);
  padding: 0 1vw;
  color: #000;
  font-family: inherit;
  font-weight: 400;
  font-size: calc(1.7 * var(--u));
  line-height: var(--thick);
  letter-spacing: normal;
  border-radius: 0;
  white-space: nowrap;
  cursor: pointer;
}
/* the bar is thin; extend the tap area upwards so it's easy to hit on a touch screen */
.key::after { content: ""; position: absolute; inset: calc(-4 * var(--u)) 0 0 0; }

/* ---- sidebar headings, one per row ---- */
.block {
  color: #000;
  font-size: calc(3.8 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1vw;
}
.block b { font-size: calc(3.8 * var(--u)); }

/* ---- content cells ---- */
.cell {
  align-self: center;
  padding: calc(1.5 * var(--u)) 0 calc(1.5 * var(--u)) 3vw;
  min-width: 0;
}


#phase-name { font-size: calc(19 * var(--u)); font-weight: 700; line-height: 1; color: var(--peach); }
#phase-remaining { font-size: calc(9 * var(--u)); color: var(--sky); }

/* ---- timeline ---- */
#timeline[hidden] { display: block !important; visibility: hidden; } /* keep layout stable */

#bar {
  position: relative;
  height: calc(6 * var(--u));
  border-radius: calc(3 * var(--u));
  background: var(--dark);
  overflow: hidden;
}
#pct {
  position: absolute;
  top: 0;
  height: 100%;
  line-height: calc(6 * var(--u));
  font-size: calc(4.5 * var(--u));
  font-weight: 700;
  color: var(--orange);
  padding: 0 1.2vw;
  transition: left 0.25s linear;
}
#pct.inside { color: #000; transform: translateX(-100%); }
#fill {
  height: 100%;
  background: var(--orange);
  border-radius: calc(3 * var(--u));
  transition: width 0.25s linear;
}

#ticks {
  display: flex;
  justify-content: space-between;
  padding: calc(0.6 * var(--u)) 1vw 0;
  font-size: calc(4.5 * var(--u));
  color: var(--blue);
}

#next { display: flex; align-items: baseline; gap: 2vw; }
#next-name { font-size: calc(8 * var(--u)); font-weight: 700; color: var(--gold); }
#next-at { font-size: calc(6 * var(--u)); color: var(--lavender); }

/* ---- editor ---- */
dialog {
  background: #000;
  color: var(--peach);
  border: none;
  border-left: 2vw solid var(--orange);
  border-radius: calc(3 * var(--u)) 0 0 calc(3 * var(--u));
  width: min(640px, 90vw);
  font-family: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.8); }
dialog h2 { color: var(--orange); margin-top: 0; letter-spacing: 0.1em; }
dialog code { color: var(--gold); }
textarea {
  width: 100%;
  background: var(--dark);
  color: var(--peach);
  border: none;
  font: 18px "Antonio", ui-monospace, Menlo, monospace;
  padding: 10px;
}
.buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
button {
  color: #000;
  border: none;
  border-radius: 20px;
  padding: 8px 24px;
  font: 700 16px "Antonio", sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
}

#editor-errors { color: var(--red); font-size: 16px; margin-top: 8px; }
textarea.has-error { box-shadow: inset 0 0 0 2px var(--red); }
textarea.has-error::selection { background: var(--red); color: #000; }
textarea { text-transform: uppercase; }

.c-sky { background: var(--sky); }
#later { position: relative; display: flex; gap: 3vw; min-height: calc(5 * var(--u)); font-size: calc(4 * var(--u)); overflow: hidden; white-space: nowrap; }
.later-name { color: var(--peach); }
.later-at { color: var(--blue); }

/* phase name left (shrinks to fit on one line), time left right */
#now { display: flex; align-items: baseline; column-gap: 3vw; }
#phase-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; }
#phase-remaining { font-size: calc(12 * var(--u)); line-height: 1; white-space: nowrap; }
.clock-label { font-size: calc(4 * var(--u)); color: var(--lavender); letter-spacing: 0.1em; }

.share { display: flex; gap: 8px; margin-top: 10px; }
#share-code {
  flex: 1;
  min-width: 0;
  background: var(--dark);
  color: var(--peach);
  border: none;
  border-radius: 20px;
  padding: 8px 14px;
  font: 14px ui-monospace, Menlo, monospace;
  text-transform: none; /* base64 is case-sensitive */
}
#share-code::placeholder { color: var(--blue); font-family: "Antonio", sans-serif; font-size: 16px; }

.c-green { background: var(--green); }
/* SHOWCLOCK title and deploy time share the same panel-code look */
.elbow.top span, #deployed { font-size: calc(2.6 * var(--u)); letter-spacing: 0.12em; }

/* ---- portrait (taller than wide) ---- */
#phase-name { --fit-max: 19; }
/* only for clearly tall screens: near-square windows lack the height for the stacked layout */
@media (max-aspect-ratio: 5/6) {
  /* later takes the spare height and clips (JS hides items that don't fit) instead of
     spilling into the bottom frame on a long day */
  .lcars { grid-template-rows: var(--frame) auto auto auto minmax(0, 1fr) var(--frame); }
  #later { align-self: stretch; }

  /* time left drops under the phase name, which can then use the full width */
  #now { flex-direction: column; align-items: flex-start; row-gap: calc(2 * var(--u)); }
  #phase-name { --fit-max: 34; width: 100%; flex: none; }
  #phase-remaining { font-size: calc(16 * var(--u)); }

  #next-name { font-size: calc(10 * var(--u)); }

  /* later: one per line so nothing is cut off */
  #later { flex-direction: column; gap: calc(1.5 * var(--u)); font-size: calc(5 * var(--u)); }
}
