/* Section timer for the Learning Styles page (see timer.js). Sits at the top right
   and uses the page's own color tokens from styles.css, so it follows the
   day/night theme. */
:root {
  --ls-timer-shadow: 0 0 0 1px rgba(21, 32, 43, 0.06), 0 0 9px rgba(21, 32, 43, 0.16);
  --ls-timer-box: var(--bg);
}
@supports (background: color-mix(in srgb, red 50%, blue)) {
  :root { --ls-timer-box: color-mix(in srgb, var(--ink) 7%, var(--surface)); }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ls-timer-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 0 11px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --ls-timer-shadow: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 0 11px rgba(0, 0, 0, 0.6);
}
@supports (background: color-mix(in srgb, red 50%, blue)) {
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --ls-timer-box: color-mix(in srgb, var(--ink) 11%, var(--surface)); }
  }
  :root[data-theme="dark"] { --ls-timer-box: color-mix(in srgb, var(--ink) 11%, var(--surface)); }
}

/* The clock and the pill are one shape. Its right edge stays put and its height
   never changes; opening only widens it, so the circle reads as splitting down
   the middle with its left half dragged out to the left. */
.ls-timer {
  --d: 48px;
  --open-w: min(320px, calc(100vw - 32px));
  position: fixed;
  z-index: 45;
  top: max(calc(var(--ls-timer-top, 0px) + 12px), calc(env(safe-area-inset-top, 0px) + 12px));
  right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px));
  width: var(--d);
  height: var(--d);
  border-radius: calc(var(--d) / 2);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--ls-timer-shadow);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.6);
  transform-origin: calc(100% - var(--d) / 2) 50%;
  /* Closing: the contents fade, then the left half slides back in */
  transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1) 0.08s, opacity 0.25s ease,
    transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), visibility 0s linear 0.3s, top 0.3s ease;
}
.ls-timer.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: width 0.32s cubic-bezier(0.4, 0, 0.2, 1) 0.08s, opacity 0.25s ease,
    transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), visibility 0s, top 0.3s ease;
}
/* Opening: the left half is dragged out with a little give at the end */
.ls-timer.is-open {
  width: var(--open-w);
  transition: width 0.44s cubic-bezier(0.22, 1.22, 0.36, 1) 0.06s, opacity 0.25s ease,
    transform 0.3s ease, visibility 0s, top 0.3s ease;
}

/* The clock face: a second hand only. Tap it to open the pill. */
.ls-timer-face {
  appearance: none;
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  width: var(--d);
  height: var(--d);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.18s ease 0.3s, visibility 0s linear 0s;
}
.ls-timer.is-open .ls-timer-face {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease 0s, visibility 0s linear 0.1s;
}
.ls-timer-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 2px;
  height: calc(var(--d) / 2 - 8px);
  margin-left: -1px;
  border-radius: 1px;
  background: var(--ink);
  transform-origin: 50% 100%;
  transition: transform 0.22s cubic-bezier(0.3, 1.8, 0.5, 1);
}
.ls-timer-hand.ls-timer-snap { transition: none; }
.ls-timer-pin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--ink);
}

/* The pill's contents, laid out at full width and revealed as it opens */
.ls-timer-card {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--open-w);
  box-sizing: border-box;
  padding: 0 calc((var(--d) - 30px) / 2) 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s ease 0s;
}
.ls-timer.is-open .ls-timer-card {
  opacity: 1;
  transition: opacity 0.2s ease 0.26s;
}
.ls-timer-text {
  appearance: none;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.ls-timer-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 13.5px/1.15 "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
}
.ls-timer-hint {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 10.5px/1.25 "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.ls-timer-time {
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: default;
}
/* Each number sits in a tinted box with its own up/down chevrons, so it reads as editable */
.ls-timer-field {
  display: flex;
  align-items: center;
  height: 32px;
  padding-left: 2px;
  border-radius: 8px;
  background: var(--ls-timer-box);
}
.ls-timer-num {
  appearance: none;
  box-sizing: border-box;
  width: 26px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: 500 15px/32px "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
  caret-color: var(--blue);
}
.ls-timer-spin {
  display: flex;
  flex-direction: column;
  width: 16px;
  height: 32px;
}
.ls-timer-step {
  appearance: none;
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
/* A bigger touch target than the chevron itself */
.ls-timer-step::after {
  content: "";
  position: absolute;
  inset: 0 -6px 0 -2px;
}
.ls-timer-step svg {
  width: 9px;
  height: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ls-timer-step:hover { color: var(--ink); }
.ls-timer-colon {
  margin: 0 1px;
  font: 500 15px/1 "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
}
/* Reset sits in the right end, where the clock was */
.ls-timer-reset {
  appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ls-timer-box);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.ls-timer-reset svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ls-timer-face:focus-visible,
.ls-timer-text:focus-visible,
.ls-timer-step:focus-visible,
.ls-timer-num:focus-visible,
.ls-timer-reset:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.ls-timer-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .ls-timer,
  .ls-timer.is-on,
  .ls-timer.is-open,
  .ls-timer-face,
  .ls-timer.is-open .ls-timer-face,
  .ls-timer-card,
  .ls-timer.is-open .ls-timer-card,
  .ls-timer-hand {
    transition-duration: 0.01s;
    transition-delay: 0s;
  }
}

@media print {
  .ls-timer { display: none; }
}
