/* The duo's web interface: phone first, then tablet and desktop. The yellow is the Template's. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #17171a;
  --muted: #5f5f66;
  --line: #deddd6;
  --accent: #ffd400;
  --accent-text: #111111;
  --focus: #1f6feb;
  --ready: #1b7a3d;
  --ready-bg: #e3f4e8;
  --review: #9a5200;
  --review-bg: #fdf0dd;
  --generating: #2349a8;
  --generating-bg: #e4ebfb;
  --idle-bg: #ecebe6;
  --error: #b42318;
  --error-bg: #fdecea;
  --radius: 12px;
  --tap: 48px; /* the smallest thing a finger presses */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1c1c20;
    --text: #f1f1f3;
    --muted: #a3a3ad;
    --line: #34343b;
    --focus: #6ea8ff;
    --ready: #7fdc9b;
    --ready-bg: #173523;
    --review: #ffbd6b;
    --review-bg: #3b2a12;
    --generating: #a9c1ff;
    --generating-bg: #1d2a4d;
    --idle-bg: #2a2a30;
    --error: #ff9a8f;
    --error-bg: #3d1a17;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

main, .bar, .login {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

main { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 20px 0 4px; }

h2 { font-size: 1rem; margin: 0; }

a { color: inherit; }

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

.hint, .video-meta, small { color: var(--muted); }

.hint { margin: 4px 0 12px; font-size: 0.95rem; }

/* Top bar */

.bar { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; border-bottom: 1px solid var(--line); }

.brand { font-weight: 700; text-decoration: none; letter-spacing: 0.01em; }

.brand::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.45em;
  border-radius: 3px;
  background: var(--accent);
  vertical-align: 0.02em;
}

/* Buttons */

button, select, input { font: inherit; color: inherit; }

button {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { cursor: not-allowed; opacity: 0.45; }

.primary {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Messages */

.status { color: var(--muted); }

.error, .notice, .problem {
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 8px 0;
}

.error, .problem { background: var(--error-bg); color: var(--error); }

.notice { background: var(--generating-bg); color: var(--generating); }

/* The Inbox */

.videos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.video {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  text-align: left;
}

.video-name { font-weight: 650; }

.video-date { grid-column: 1; color: var(--muted); font-size: 0.92rem; }

.video .state { grid-column: 2; grid-row: 1 / span 2; }

.video .problem { grid-column: 1 / -1; margin: 6px 0 0; font-size: 0.92rem; }

.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 650;
  background: var(--idle-bg);
  color: var(--muted);
}

.state-ready { background: var(--ready-bg); color: var(--ready); }

.state-review { background: var(--review-bg); color: var(--review); }

.state-generating { background: var(--generating-bg); color: var(--generating); }

.state-generating::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) { .state-generating::before { animation: none; } }

/* The form */

.back {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  margin-top: 8px;
  font-weight: 600;
  text-decoration: none;
}

.video-meta { margin: 4px 0 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.field { display: block; margin: 0 0 22px; }

fieldset.field { border: 0; padding: 0; min-width: 0; }

label, legend { display: block; font-weight: 650; margin-bottom: 6px; padding: 0; }

select, input[type="text"], input[type="password"] {
  display: block;
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
}

.sequence { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.occurrence {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.occurrence-number { color: var(--muted); font-variant-numeric: tabular-nums; }

.occurrence-name { font-weight: 600; }

.occurrence-beats { display: block; color: var(--muted); font-size: 0.9rem; font-weight: 400; }

.occurrence-buttons { display: flex; gap: 4px; }

.occurrence-buttons button { width: var(--tap); padding: 0; font-size: 1.1rem; }

.total { margin: 18px 0 8px; font-weight: 650; }

.total.empty { font-weight: 400; color: var(--muted); }

/* One Figure per line on a phone, two side by side from a tablet up. */
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }

.figures button {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  font-weight: 600;
}

.figures button::before { content: "+"; font-size: 1.25rem; line-height: 1; color: var(--muted); }

.figures button span {
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* The Beat Counter switch */

.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; font-weight: 600; }

.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.switch-track {
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: var(--line);
  transition: background 0.15s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.switch input:checked + .switch-track { background: var(--accent); }

.switch input:checked + .switch-track::after { transform: translateX(20px); }

.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Generate stays in reach of the thumb at the bottom of the screen. */
.actions {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

/* Login */

.login { padding-top: 12vh; max-width: 420px; }

.login form { display: grid; gap: 12px; }

.login input { margin-bottom: 4px; }

/* Tablet and desktop: more room around, Figures in more columns. */

@media (min-width: 700px) {
  h1 { font-size: 2rem; margin-top: 28px; }
  .video { padding: 14px 18px; }
  .actions { margin: 0; padding-left: 0; padding-right: 0; }
}
