/* Loopwright — Metronome Ribbon Stack theme */

:root {
  --ink: #17242b;
  --ink-soft: #3c5160;
  --paper: #f3f0e4;
  --card: #fdfbf0;
  --lime: #c6f45a;
  --lime-deep: #a9d63c;
  --coral: #ff8674;
  --cobalt: #7ea6e0;
  --sand: #e9d49a;
  --line: rgba(23, 36, 43, 0.16);
  --radius: 14px;
  --side-pad: 16px;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; /* 16px+ prevents iOS zoom on focus */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

/* ---------- header ---------- */

.top-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--side-pad) 10px;
  border-bottom: 3px dotted var(--line);
  background: var(--paper);
}

.fork-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex: none;
}

.fork-mark svg { width: 26px; height: 26px; }

.top-copy h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.top-copy p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- layout ---------- */

main { display: block; }

.view {
  padding: 14px var(--side-pad) 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.section-head h2,
.deck-head h2 {
  margin: 0;
  font-size: 18px;
}

.count-chip {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink);
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
}

.deck-head { margin: 0; }
.deck-head h2 { font-size: 16px; color: var(--ink-soft); }

/* ---------- ribbons ---------- */

.ribbon {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  min-height: 60px;
  overflow: hidden;
  box-shadow: 3px 3px 0 rgba(23, 36, 43, 0.18);
}

.ribbon.stripe-wrap { cursor: pointer; }
.ribbon-row { cursor: pointer; }

.ribbon-stripe {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 14px;
}

.stripe-lime   { background: var(--lime); }
.stripe-coral  { background: var(--coral); }
.stripe-cobalt { background: var(--cobalt); }
.stripe-sand   { background: var(--sand); }

.ribbon-notches {
  position: absolute;
  top: 8px;
  left: 26px; right: 14px;
  border-top: 3px dotted rgba(23, 36, 43, 0.35);
}

.ribbon-body {
  padding: 18px 14px 12px 26px;
}

.ribbon-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ribbon-cue {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  padding-top: 6px;
}

.tempo-badge {
  flex: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--ink);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tempo-badge b { font-size: 15px; }
.tempo-badge i { font-style: normal; font-size: 8px; letter-spacing: 1px; margin-top: 2px; }

.ribbon-title {
  margin: 6px 0 2px;
  font-size: 17px;
  line-height: 1.25;
}

.ribbon-focus .ribbon-title { font-size: 20px; }

.ribbon-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.ribbon-note-empty { font-style: italic; opacity: 0.7; }

.ribbon-meta {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.8;
}

.tap-hint {
  display: block;
  padding: 0 14px 10px 26px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
  opacity: 0.65;
}

.row-delete {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px; height: 36px;
  min-width: 36px; min-height: 36px; /* thumb-sized */
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.row-delete:active { background: var(--coral); }

/* ---------- Deck specifics ---------- */

.focus-wrap {
  position: relative;
  margin-top: 14px;
}

.coin {
  position: absolute;
  top: -16px;
  right: -8px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--lime);
  border: 2px solid var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 2;
  box-shadow: 2px 3px 0 rgba(23, 36, 43, 0.25);
}

.coin b { font-size: 20px; line-height: 1; }
.coin i { font-style: normal; font-size: 7px; font-weight: 700; letter-spacing: 0.8px; margin-top: 2px; }

.focus-wrap .ribbon { overflow: visible; }
.focus-wrap .ribbon .ribbon-stripe { border-radius: var(--radius) 0 0 var(--radius); }

.add-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--lime);
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(23, 36, 43, 0.18);
}

.add-strip:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(23, 36, 43, 0.18); }

.add-plus {
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.deck-secondary h3 {
  margin: 6px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-soft);
}

.mini-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Loops grouping ---------- */

.loop-group { display: flex; flex-direction: column; gap: 12px; }

.loop-group + .loop-group { margin-top: 6px; }

.group-title {
  margin: 10px 0 0;
  font-size: 15px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.group-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- Forms ---------- */

.drill-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 3px 3px 0 rgba(23, 36, 43, 0.18);
}

.form-hint {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

.req {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #b3402f;
}

.opt {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 12px 12px;
  min-height: 46px;
  width: 100%;
  appearance: none;
}

.field textarea { resize: vertical; }

.field input:focus,
.field textarea:focus {
  outline: 3px solid var(--lime);
  outline-offset: 1px;
}

.error-list {
  margin: 0;
  padding: 10px 12px 10px 28px;
  background: #fbe9e2;
  border: 2px solid #b3402f;
  border-radius: 10px;
  font-size: 13px;
  color: #7c2417;
}

.error-list li + li { margin-top: 4px; }

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  cursor: pointer;
}

.btn-lime {
  background: var(--lime);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(23, 36, 43, 0.18);
}

.btn-lime:active { transform: translateY(1px); box-shadow: 1px 1px 0 rgba(23, 36, 43, 0.18); }

.btn-ghost {
  background: var(--card);
  color: var(--ink);
}

.btn-ghost-danger {
  background: var(--card);
  color: #b3402f;
  border-color: #b3402f;
}

.btn-ghost-danger:active { background: #fbe9e2; }

/* ---------- Find ---------- */

.search-field { margin: 0; }

.search-field input {
  border-radius: 999px;
  padding-left: 16px;
}

.result-line {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ---------- Empty states ---------- */

.empty-state {
  text-align: center;
  padding: 26px 18px;
  border: 3px dotted var(--line);
  border-radius: var(--radius);
  background: rgba(253, 251, 240, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.empty-fork { color: var(--ink-soft); opacity: 0.6; }
.empty-fork svg { width: 34px; height: 34px; }

.empty-state h3 { margin: 4px 0 0; font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; color: var(--ink-soft); max-width: 34ch; }
.empty-state .btn { margin-top: 10px; }

/* ---------- About / Settings footer (Find tab only) ---------- */

.about-footer {
  margin-top: 8px;
  padding: 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
}

.about-footer h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--lime);
}

.about-footer p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
}

.stat-line { font-weight: 700; color: var(--lime); }

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-actions .btn {
  min-height: 44px;
  font-size: 14px;
  background: transparent;
  color: var(--paper);
  border-color: rgba(243, 240, 228, 0.5);
}

.settings-actions .btn-ghost-danger {
  color: var(--coral);
  border-color: var(--coral);
}

/* ---------- Bottom tab bar ---------- */

.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  background: var(--ink);
  border-top: 3px dotted rgba(243, 240, 228, 0.3);
  display: flex;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: 0;
  color: rgba(243, 240, 228, 0.55);
  cursor: pointer;
  padding: 6px 0;
  min-height: 56px; /* thumb-sized targets */
}

.tab-fork svg { width: 24px; height: 24px; }

.tab-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.tab-btn.active { color: var(--lime); }

.tab-btn.active .tab-fork {
  transform: rotate(-12deg);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.5));
  transition: transform 0.15s ease, filter 0.15s ease;
}

.tab-btn:active .tab-fork { transform: rotate(-8deg); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--lime);
  border: 2px solid var(--lime);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  max-width: calc(100vw - 32px);
  text-align: center;
  z-index: 20;
  box-shadow: 0 4px 10px rgba(23, 36, 43, 0.35);
}

/* ---------- Small screens / wide screens ---------- */

@media (min-width: 560px) {
  .view {
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
  }
}
