/* Row viewer — Design Crochet tokens from ../css/app.css (design_specs.txt) */

/*
 * Tight vertical stack, full usable width for horizontal chart.
 * html.row-page-root is set inline (row/index.html) to beat app.css min-height: 100%.
 */
html.row-page-root,
html:has(body.row-page) {
  min-height: unset !important;
  width: 100%;
  height: auto;
  /* max-content: shrink document to content (fit-content can still stretch in some UAs) */
  height: max-content;
  max-height: 100dvh;
  overflow: hidden;
  overflow-y: hidden;
  overscroll-behavior-y: none;
}

body.row-page {
  /* Tab bar + toolbar + chrome; taller chart before scale-down */
  --row-chart-max-viewport-height: calc(100dvh - 12.5rem);
  box-sizing: border-box;
  width: 100%;
  height: auto;
  height: max-content;
  max-height: 100dvh;
  min-height: unset !important;
  margin: 0;
  overflow: hidden;
  overflow-y: hidden;
  overscroll-behavior-y: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: max(0.65rem, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-left, 0px)) env(safe-area-inset-bottom, 0px)
    max(12px, env(safe-area-inset-right, 0px));
}

.row-page-inner {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  align-self: stretch;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
  overflow-y: hidden;
}

.row-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  flex-shrink: 0;
  margin: 0 0 0.4rem;
}

.row-header-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 0;
}

.row-label {
  flex-shrink: 0;
  margin: 0;
  font-family: "Comfortaa", sans-serif;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--dc-navy);
}

.row-current-color {
  flex: 0 0 auto;
  text-align: right;
  min-width: 140px;
}

.row-repeat {
  flex: 0 0 auto;
  text-align: right;
  min-width: 120px;
  position: relative;
}

/* Mobile: stack title above repeat/color controls to avoid overlap */
@media (max-width: 420px) {
  .row-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .row-label {
    flex: 1 1 100%;
  }

  .row-header-right {
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .row-current-color,
  .row-repeat {
    min-width: unset;
    text-align: left;
  }

  button.row-repeat-pill {
    justify-content: flex-start;
  }

  /* Keep repeat popover fully on-screen on mobile */
  .row-repeat-popover {
    left: 0;
    right: auto;
    width: min(260px, calc(100vw - 24px));
  }
}

button.row-repeat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  margin: 0;
  padding: 0.25rem 0.55rem;
  min-height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(12, 41, 90, 0.18);
  background: rgba(255, 255, 255, 0.65);
  color: var(--dc-navy);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(12, 41, 90, 0.08);
  transition: background 0.15s ease, border-color 0.15s ease;
}

button.row-repeat-pill:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--dc-teal);
}

button.row-repeat-pill:focus-visible {
  outline: 2px solid var(--dc-teal);
  outline-offset: 2px;
}

.row-repeat-pill-label {
  font-family: "Montserrat", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--dc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.row-repeat-pill-value {
  min-width: 1.35rem;
  text-align: center;
  font-family: "Montserrat", sans-serif;
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--dc-navy);
}

.row-repeat-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(220px, calc(100vw - 24px));
  padding: 0.65rem 0.65rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(12, 41, 90, 0.16);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 22px rgba(12, 41, 90, 0.18);
  z-index: 40;
}

.row-repeat-popover-title {
  font-family: "Montserrat", sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--dc-navy);
  margin: 0 0 0.5rem;
  text-align: center;
}

.row-repeat-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.row-repeat-value {
  flex: 1;
  text-align: center;
  font-family: "Montserrat", sans-serif;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--dc-navy);
}

button.row-repeat-reset {
  margin-top: 0.55rem;
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid var(--dc-gray-border);
  background: var(--dc-gray-light);
  color: var(--dc-text-muted);
  font-family: "Comfortaa", sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button.row-repeat-reset:hover {
  background: var(--dc-white);
  border-color: var(--dc-teal);
  color: var(--dc-navy);
}

.row-repeat-help {
  margin-top: 0.5rem;
  font-family: "Montserrat", sans-serif;
  font-size: 0.8rem;
  color: var(--dc-text-muted);
  line-height: 1.25;
  text-align: center;
}

button.row-mini-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--dc-gray-border);
  background: var(--dc-gray-light);
  color: var(--dc-text-muted);
  font-family: "Comfortaa", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button.row-mini-btn:hover {
  background: var(--dc-white);
  border-color: var(--dc-teal);
  color: var(--dc-navy);
}

button.row-mini-btn:focus-visible {
  outline: 2px solid var(--dc-teal);
  outline-offset: 2px;
}

.row-current-color-label {
  font-family: "Montserrat", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--dc-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.row-current-color-swatch-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.3rem;
}

.row-current-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(12, 41, 90, 0.18);
  box-shadow: 0 1px 3px rgba(12, 41, 90, 0.12);
  background: transparent;
}

.row-current-color {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
}

.row-current-color-swatch-wrap {
  margin-top: 0;
}

.row-screen--chart {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.row-chart-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.row-chart-panel[hidden] {
  display: none !important;
}

.row-tabs {
  display: flex;
  gap: 0;
  width: 100%;
  margin: 0 0 0.35rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--dc-gray-border);
  padding: 0;
}

.row-tabs.row-tabs--single .row-tab[hidden] {
  display: none;
}

.row-tab {
  flex: 1;
  box-sizing: border-box;
  font-family: "Comfortaa", sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.55rem 0.65rem 0.45rem;
  min-height: 44px;
  margin: 0;
  border: none;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--dc-text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  box-shadow: none;
}

.row-tab:hover {
  color: var(--dc-teal);
}

.row-tab[aria-selected="true"] {
  color: var(--dc-navy);
  border-bottom-color: var(--dc-navy);
  font-weight: 700;
}

.row-tab:focus-visible {
  outline: 2px solid var(--dc-teal);
  outline-offset: -2px;
}

.row-panel[hidden] {
  display: none !important;
}

.row-panel.row-panel--active {
  display: block;
}

.row-scroll-wrap,
.row-progress-slot {
  flex: 0 1 auto;
  width: 100%;
  margin-bottom: 0.45rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--dc-gray-border);
  border-radius: var(--radius);
  box-shadow: var(--dc-shadow);
  background: linear-gradient(
    165deg,
    rgba(137, 209, 140, 0.18) 0%,
    var(--dc-white) 55%,
    var(--dc-white) 100%
  );
  overflow: hidden;
  overflow-y: hidden;
}

.row-progress-slot[hidden] {
  display: none !important;
}

/* Progress now sits directly under the header (no tab-row spacer). */

.row-scroll {
  width: 100%;
  max-height: var(--row-chart-max-viewport-height);
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  background: var(--dc-white);
}

.row-scroll img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  max-height: var(--row-chart-max-viewport-height);
  object-fit: contain;
}

.row-scroll.row-scroll--fit {
  overflow-x: hidden;
  touch-action: pan-y;
}

.row-scroll.row-scroll--fit img {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.row-scroll.row-scroll--locked {
  touch-action: none;
}

/* Toolbar: secondary lock + primary mark complete */
.row-chart-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  flex-shrink: 0;
  margin: 0 0 0.15rem;
}

.row-mark-complete-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.row-mark-complete-btn[hidden] {
  display: none !important;
}

button.row-lock-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--dc-text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

button.row-lock-icon-btn:hover:not(:disabled) {
  color: var(--dc-navy);
  background: rgba(12, 41, 90, 0.06);
}

button.row-lock-icon-btn:focus-visible {
  outline: 2px solid var(--dc-teal);
  outline-offset: 2px;
}

button.row-lock-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

button.row-lock-icon-btn[aria-pressed="true"] {
  color: var(--dc-teal);
}

.row-lock-icon[hidden] {
  display: none !important;
}

/* Progress (aligned with track/); --in-slot sits inside .row-progress-slot (diagram region) */
.row-progress-card {
  width: 100%;
  background: var(--dc-white);
  border: 1px solid var(--dc-gray-border);
  border-radius: var(--radius);
  box-shadow: var(--dc-shadow);
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  text-align: center;
}

.row-progress-card--in-slot {
  border: none;
  box-shadow: none;
  border-radius: 8px;
  min-height: min(240px, var(--row-chart-max-viewport-height));
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.row-progress-pattern-name {
  margin: 0 0 0.85rem;
  font-family: "Lexend", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--dc-navy);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.row-community-nudge {
  margin-top: 0.85rem;
  font-family: "Montserrat", sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dc-text-muted);
  line-height: 1.35;
  text-align: center;
}

/* Scarf progress — simple bar + endcap icon */
.row-scarf {
  position: relative;
  width: 100%;
  margin: 0 0 0.65rem;
  padding: 12px 2px 10px;
}

.row-scarf-track {
  --scarf-pct: 0%;
  position: relative;
  width: 100%;
  height: 26px;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(12, 41, 90, 0.12),
    0 2px 8px rgba(12, 41, 90, 0.08);
  background: var(--dc-gray-light);
  border: 1px solid rgba(12, 41, 90, 0.12);
}

.row-scarf-track-wrap {
  position: relative;
  width: 100%;
  overflow: visible;
}

/* Base fill underlay (keeps subtle depth) */
.row-scarf-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(12, 41, 90, 0.04) 0%,
    rgba(12, 41, 90, 0.01) 35%,
    rgba(12, 41, 90, 0.03) 100%
  );
  pointer-events: none;
}

.row-scarf-fg-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  clip-path: inset(0 calc(100% - var(--scarf-pct)) 0 0);
  transition: clip-path 0.28s ease;
  pointer-events: none;
}

.row-scarf-fg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #25b2bb 0%, #1b9aa0 60%, #168896 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.row-scarf-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  z-index: 3;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  line-height: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 1px 3px rgba(12, 41, 90, 0.28));
  transition: left 0.28s ease;
}

.row-scarf-endcap {
  position: absolute;
  top: 50%;
  left: 0%;
  z-index: 2;
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(12, 41, 90, 0.25));
  transition: left 0.28s ease;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}

.row-scarf-endcap-img {
  display: block;
  width: 30px;
  height: 30px;
}


.row-scarf-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.65rem;
  margin: 0 0 0.85rem;
}

button.row-scarf-ctrl-btn {
  min-width: 40px;
  min-height: 40px;
  padding: 0 0.55rem;
  margin: 0;
  font-family: "Comfortaa", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  color: var(--dc-text-muted);
  background: var(--dc-gray-light);
  border: 1px solid var(--dc-gray-border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button.row-scarf-ctrl-btn--text {
  min-width: unset;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.65rem;
}

button.row-scarf-ctrl-btn:hover {
  color: var(--dc-navy);
  border-color: var(--dc-teal);
  background: var(--dc-white);
}

button.row-scarf-ctrl-btn:focus-visible {
  outline: 2px solid var(--dc-teal);
  outline-offset: 2px;
}

.row-progress-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.row-progress-btn {
  width: 100%;
  font-size: 1rem;
  min-height: 52px;
}

@media (min-width: 520px) {
  .row-progress-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .row-progress-actions .row-progress-btn {
    width: auto;
    flex: 1;
    min-width: 160px;
  }
}

/* Celebration overlay */
.row-celebrate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.row-celebrate[hidden] {
  display: none !important;
}

.row-celebrate-confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.row-confetti-piece {
  position: absolute;
  top: 36%;
  left: var(--cx, 50%);
  width: 7px;
  height: 10px;
  border-radius: 2px;
  background: var(--cc, var(--dc-teal));
  opacity: 0.95;
  transform: translateX(-50%);
  animation: row-confetti-fall 1.35s ease-out forwards;
  animation-delay: var(--cd, 0s);
}

@keyframes row-confetti-fall {
  0% {
    transform: translateX(-50%) translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(120px) rotate(680deg) scale(0.5);
    opacity: 0;
  }
}

.row-celebrate-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 42%,
    rgba(137, 209, 140, 0.45) 0%,
    rgba(255, 255, 255, 0.92) 55%,
    rgba(255, 255, 255, 0.98) 100%
  );
  animation: row-celebrate-fade 1.8s ease forwards;
}

@keyframes row-celebrate-fade {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.row-celebrate-content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: row-celebrate-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes row-celebrate-pop {
  0% {
    transform: scale(0.4);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.row-celebrate-check {
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  line-height: 1;
  color: var(--dc-green);
  text-shadow: 0 2px 12px rgba(137, 209, 140, 0.5);
  font-weight: 700;
}

.row-celebrate-title {
  margin: 0.5rem 0 0;
  font-family: "Comfortaa", sans-serif;
  font-size: clamp(1.15rem, 4vw, 1.35rem);
  font-weight: 700;
  color: var(--dc-navy);
}

.row-celebrate.row-celebrate--active {
  pointer-events: auto;
}
