/* Study Cycle for the web. Same colors as the app: green for focus, blue for breaks, orange when
   paused. The darker shades are used in light mode so white text meets WCAG AA. */

:root {
  --focus: #2f7a4a;
  --rest: #1f6fa8;
  --paused: #b4532a;
  --on-accent: #ffffff;
  --ink: #16242e;
  --muted: #4a5a66;
  --paper: #f7f9fc;
  --card: #ffffff;
  --line: #dde6ec;
  --bar: #1f6fa8;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent: var(--focus);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --focus: #5db075;
    --rest: #3e92cc;
    --paused: #ffa279;
    --on-accent: #000000;
    --ink: #e4ecf1;
    --muted: #a7b6c0;
    --paper: #10191f;
    --card: #19252d;
    --line: #2a3a44;
    --bar: #3e92cc;
  }
}

body[data-phase="focus"] { --accent: var(--focus); }
body[data-phase="rest"] { --accent: var(--rest); }
body[data-phase="paused"] { --accent: var(--paused); }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--rest);
}

[hidden] {
  display: none !important;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 24px;
  height: 24px;
  flex: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--rest);
  outline-offset: 2px;
}

/* App bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.bar-inner {
  max-width: 640px;
  margin: 0 auto;
  min-height: 60px;
  padding: 6px 8px 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bar-main img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.bar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
  white-space: nowrap;
}

.bar-actions {
  display: flex;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--ink);
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.bar-main .icon-btn {
  margin-left: -12px;
}

/* Views */

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

#view-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.dial {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 1;
  margin: 12px auto 20px;
}

.dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track,
.ring-fill {
  fill: none;
  stroke-width: 12;
}

.ring-track {
  stroke: color-mix(in srgb, var(--accent) 16%, transparent);
}

.ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 0.9s linear, stroke 0.3s;
}

.dial-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dial-label {
  color: var(--accent);
  font-size: 20px;
  font-weight: 500;
}

.dial-time {
  color: var(--accent);
  font-size: clamp(44px, 15vw, 64px);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.dial-cycle {
  min-height: 1.5em;
  font-size: 16px;
}

.guidance {
  max-width: 34em;
  margin: 0 0 28px;
  font-size: 19px;
  font-weight: 500;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 210px;
  min-height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font: 500 19px/1 var(--sans);
  cursor: pointer;
  transition: background 0.3s, transform 0.1s;
}

.primary-btn:active {
  transform: scale(0.98);
}

.secondary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--rest);
  font: 500 16px/1 var(--sans);
  cursor: pointer;
}

.text-btn svg {
  width: 20px;
  height: 20px;
}

.text-btn:hover {
  background: color-mix(in srgb, var(--rest) 10%, transparent);
}

.text-btn.danger {
  color: #c0392b;
}

.today {
  margin: 28px 0 0;
  color: var(--muted);
}

.web-note {
  max-width: 34em;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.banner {
  width: 100%;
  margin: 0 0 8px;
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--rest) 14%, var(--card));
  text-align: left;
  font-size: 15px;
}

.banner p {
  margin: 0;
}

.note-box {
  max-width: 640px;
  margin: 24px auto;
  padding: 16px;
  border-radius: 14px;
  background: var(--card);
}

/* Progress */

.cards.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  margin: 0 0 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}

.card h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.big {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.2;
}

.detail {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.chart li {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.chart .bar {
  width: 100%;
  max-width: 36px;
  border-radius: 6px 6px 2px 2px;
  background: var(--focus);
}

.chart .day {
  color: var(--muted);
  font-size: 13px;
}

.small {
  color: var(--muted);
  font-size: 14px;
}

.center {
  text-align: center;
}

/* Settings */

.group {
  margin: 0 0 20px;
  padding: 4px 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.group legend {
  padding: 8px 0;
  color: var(--rest);
  font-size: 15px;
  font-weight: 600;
}

.radio-row,
.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 0;
  cursor: pointer;
}

.switch-row {
  justify-content: space-between;
}

.row-title {
  display: block;
}

.row-sub {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.radio-row input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex: none;
  accent-color: var(--rest);
}

.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transform: translateY(-50%);
  transition: left 0.2s, width 0.2s, height 0.2s, background 0.2s;
}

.switch:checked {
  border-color: var(--rest);
  background: var(--rest);
}

.switch:checked::after {
  left: 24px;
  width: 22px;
  height: 22px;
  background: var(--on-accent);
}

.switch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.slider {
  display: block;
  padding: 8px 0;
}

.slider-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  font-weight: 500;
}

.slider input {
  width: 100%;
  min-height: 36px;
  accent-color: var(--rest);
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert-row p {
  margin: 8px 0;
}

/* About */

.prose h2 {
  margin: 28px 0 8px;
  font-size: 21px;
}

.prose h2:first-child {
  margin-top: 8px;
}

.prose h3 {
  margin: 16px 0 4px;
  font-size: 16px;
}

.refs {
  padding-left: 20px;
  font-size: 14px;
}

.refs li {
  margin-bottom: 6px;
}

.prose a {
  overflow-wrap: anywhere;
}

/* Dialogs */

dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 20px 20px 12px;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 500;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 16px;
}

/* Footer */

.foot {
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.foot a {
  color: var(--muted);
}

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

  .bar h1 {
    font-size: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ring-fill,
  .primary-btn,
  .switch,
  .switch::after {
    transition: none;
  }
}
