/* ============================================================
   SKEIN — every day, a row
   Warm textile aesthetic: cream wool, deep ink, terracotta.
   ============================================================ */

:root {
  --paper: #f7f1e5;
  --paper-deep: #efe6d3;
  --card: #fdfaf3;
  --ink: #2b2118;
  --ink-soft: #6b5d4d;
  --ink-faint: #a4937d;
  --accent: #c65f3c;
  --accent-deep: #9c4326;
  --thread: #d8c9ae;
  --shadow: 0 1px 2px rgba(43, 33, 24, 0.06), 0 8px 24px -8px rgba(43, 33, 24, 0.18);
  --shadow-lift: 0 2px 4px rgba(43, 33, 24, 0.08), 0 18px 40px -12px rgba(43, 33, 24, 0.28);
  --font-display: "Fraunces", serif;
  --font-body: "Instrument Sans", sans-serif;
  --font-mono: "Spline Sans Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(198, 95, 60, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(198, 95, 60, 0.05), transparent 55%),
    var(--paper);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); }

/* --- grain overlay --- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ masthead ============ */

.masthead {
  max-width: 1060px;
  margin: 0 auto;
  padding: 44px 28px 8px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; }

.yarnball { width: 52px; height: 52px; }
.yarnball .strand,
.yarnball .tail {
  fill: none;
  stroke: rgba(247, 241, 229, 0.75);
  stroke-width: 2.4;
  stroke-linecap: round;
}
.yarnball .tail { stroke: var(--accent-deep); stroke-width: 3; }

.brand-name {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: 44px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand-name .ch { display: inline-block; }

.tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 4px;
}

/* --- nav tabs --- */
.views {
  position: relative;
  display: flex;
  gap: 4px;
  background: var(--paper-deep);
  border: 1px dashed var(--thread);
  border-radius: 999px;
  padding: 5px;
}

.view-tab {
  position: relative;
  z-index: 1;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: color 0.25s ease;
}
.view-tab:hover { color: var(--ink); }
.view-tab.is-active { color: var(--card); }

.tab-thread {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: 999px;
  background: var(--ink);
  z-index: 0;
  box-shadow: var(--shadow);
}

/* ============ layout ============ */

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  position: relative;
}

.view { display: none; }
.view.is-active { display: block; }

.section-head { margin-bottom: 22px; }
.section-head h2 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 540;
  letter-spacing: -0.015em;
}
.section-head h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 540;
}
.muted { color: var(--ink-soft); font-size: 15px; }
.footnote { color: var(--ink-faint); font-size: 13px; margin-top: 18px; }
.footnote.center { text-align: center; }

.kicker {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

/* ============ today ============ */

.today-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 56px;
  align-items: center;
  padding: 26px 0 40px;
}

.today-color-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(56px, 8vw, 96px);
  font-weight: 480;
  letter-spacing: -0.025em;
  line-height: 0.98;
  margin-bottom: 18px;
}

.today-lede {
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 46ch;
  margin-bottom: 30px;
}

.today-meta {
  display: flex;
  gap: 0;
  border-top: 1px dashed var(--thread);
  border-bottom: 1px dashed var(--thread);
}
.meta-cell {
  flex: 1;
  padding: 14px 18px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-cell + .meta-cell {
  border-left: 1px dashed var(--thread);
  padding-left: 18px;
}
.meta-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.meta-value { font-size: 19px; font-weight: 500; }

/* --- swatch card: a paint-chip / yarn tag --- */
.swatch-card {
  position: relative;
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow-lift);
  transform: rotate(1.6deg);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease;
}
.swatch-card:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: 0 4px 8px rgba(43,33,24,.1), 0 28px 56px -16px rgba(43,33,24,.35);
}

.swatch-color {
  height: 300px;
  border-radius: 8px;
  background: var(--paper-deep);
  position: relative;
  overflow: hidden;
}
.swatch-color::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(-42deg, rgba(255,255,255,0.09) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(48deg, rgba(0,0,0,0.05) 0 1px, transparent 1px 9px);
}

.swatch-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 6px 6px;
}
.swatch-name {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 560;
  font-style: italic;
}
.swatch-range { font-size: 13px; color: var(--ink-soft); }

.swatch-pin {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.25), 0 2px 4px rgba(43,33,24,0.3);
}

/* --- recent rows strip --- */
.recent-rows { padding-top: 26px; border-top: 1px dashed var(--thread); }
.recent-rows .section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.mini-blanket {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
}
.mini-blanket .row { height: 22px; }

/* ============ blanket ============ */

.range-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 34px;
}

.presets { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--thread);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--card); }

.date-inputs {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.date-field input {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--thread);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.2s ease;
}
.date-field input:focus { border-color: var(--accent); }

.btn-primary {
  font-family: var(--font-body);
  font-weight: 650;
  font-size: 14.5px;
  color: var(--card);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 10px 24px;
  cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(198, 95, 60, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn-primary:hover {
  background: var(--accent-deep);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -6px rgba(198, 95, 60, 0.7);
}

.btn-ghost {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
  background: none;
  border: 1px dashed var(--thread);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-soft); }
.btn-ghost.danger:hover { color: var(--accent-deep); border-color: var(--accent-deep); }

/* --- the blanket itself --- */
.blanket-stage { position: relative; }

.blanket-wrap {
  position: relative;
  padding: 0 18px;
}

.blanket {
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-lift);
  background: var(--card);
  min-height: 60px;
}

.blanket:empty {
  display: grid;
  place-items: center;
  min-height: 200px;
  border: 1px dashed var(--thread);
  box-shadow: none;
  background: transparent;
}

.row {
  height: 14px;
  position: relative;
  transform-origin: left center;
}
.row::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.10) 0 3px, transparent 3px 9px, rgba(0,0,0,0.05) 9px 12px, transparent 12px 18px);
  mix-blend-mode: soft-light;
  pointer-events: none;
}
.row:hover { filter: brightness(1.08); }

.fringe {
  height: 16px;
  margin: 0 26px;
  background-image: repeating-linear-gradient(90deg, var(--thread) 0 3px, transparent 3px 11px);
  opacity: 0.9;
}
.fringe-top { border-radius: 3px 3px 0 0; }
.fringe-bottom { border-radius: 0 0 3px 3px; }

.blanket-status {
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
  padding: 18px 0 4px;
  min-height: 40px;
}

/* --- stats --- */
.blanket-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 26px;
}
.stat-card {
  background: var(--card);
  border: 1px solid rgba(216, 201, 174, 0.55);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .meta-label { display: block; margin-bottom: 6px; }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 560;
  line-height: 1.1;
}
.stat-card .stat-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 3px;
}

.tally {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
}
.tally-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.tally-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.2);
}

/* ============ calendar ============ */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-bottom: 26px;
}
.cal-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 540;
  min-width: 300px;
  text-align: center;
}
.cal-nav {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px dashed var(--thread);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}
.cal-nav:hover { color: var(--accent); border-color: var(--accent); transform: scale(1.06); }
.cal-nav:disabled { opacity: 0.3; cursor: default; transform: none; }

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cal-cell {
  position: relative;
  aspect-ratio: 1 / 0.86;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid rgba(216, 201, 174, 0.45);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cal-cell.has-temp:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  z-index: 2;
}
.cal-cell.is-empty { background: transparent; border-color: transparent; }
.cal-cell.is-future { opacity: 0.45; }
.cal-cell.is-today { border: 2px solid var(--accent); }

.cal-daynum {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}
.cal-temp {
  font-family: var(--font-display);
  font-size: clamp(16px, 2.4vw, 24px);
  font-weight: 560;
  line-height: 1;
}
.cal-temp small { font-size: 0.6em; font-weight: 400; color: var(--ink-soft); }
.cal-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.25);
}

/* ============ palette ============ */

.palette-preview {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  height: 68px;
}
.preview-band {
  flex: 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  transition: flex 0.3s ease;
}
.preview-band:hover { flex: 1.6; }
.preview-band span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  white-space: nowrap;
}

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

.band-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 16px;
  align-items: center;
  background: var(--card);
  border: 1px solid rgba(216, 201, 174, 0.55);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.band-color {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  background: none;
}
.band-color::-webkit-color-swatch-wrapper { padding: 0; }
.band-color::-webkit-color-swatch { border: none; border-radius: 10px; box-shadow: inset 0 -3px 6px rgba(0,0,0,0.18); }

.band-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 540;
  font-style: italic;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  outline: none;
  padding: 2px 0;
  min-width: 0;
  transition: border-color 0.2s ease;
}
.band-name:hover, .band-name:focus { border-bottom-color: var(--thread); }

.band-range {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.band-max {
  font-family: var(--font-mono);
  font-size: 15px;
  width: 64px;
  text-align: center;
  background: var(--paper-deep);
  border: 1px solid var(--thread);
  border-radius: 8px;
  padding: 6px 4px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease;
}
.band-max:focus { border-color: var(--accent); }

.band-remove {
  font-family: var(--font-mono);
  font-size: 15px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px dashed transparent;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  transition: all 0.2s ease;
}
.band-remove:hover { color: var(--accent-deep); border-color: var(--accent-deep); }

.palette-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ============ colophon / tooltip ============ */

.colophon {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px;
  border-top: 1px dashed var(--thread);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.colophon .mono { font-size: 11.5px; }

.tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}
.tooltip.is-visible { opacity: 1; transform: translateY(0); }
.tooltip .tt-name { color: #f0c9a8; }

/* --- yarn spinner --- */
.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px dashed var(--accent);
  animation: spin 1.6s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-note {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
  padding: 20px;
}

/* ============ responsive ============ */

@media (max-width: 860px) {
  .masthead { padding: 28px 20px 4px; justify-content: center; }
  .brand { width: 100%; justify-content: center; text-align: center; }
  main { padding: 28px 18px 60px; }
  .today-grid { grid-template-columns: 1fr; gap: 36px; }
  .swatch-card { max-width: 360px; margin: 0 auto; }
  .swatch-color { height: 220px; }
  .today-color-name { font-size: clamp(44px, 12vw, 72px); }
  .band-row { grid-template-columns: 46px 1fr auto; grid-auto-rows: auto; }
  .band-range { grid-column: 1 / -1; }
  .cal-title { min-width: 0; font-size: 24px; }
  .cal-dow span { font-size: 9px; }
  .cal-temp { font-size: 13px; }
  .cal-dot { width: 8px; height: 8px; top: 6px; right: 6px; }
  .cal-cell { padding: 6px 7px; border-radius: 7px; }
  .calendar, .cal-dow { gap: 4px; }
  .views { order: 3; }
}
