:root {
  --page-background: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --surface-primary: #ffffff;
  --surface-secondary: #f1f5f9;
  --surface-ingredient: #fafafa;

  --border-light: #cbd5e1;
  --border-medium: #94a3b8;
  --accent: #1EADC3;

  --ingredient-column-width: 200px;
  --stage-column-width: 160px;
  --grid-min-width: 1000px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem;
  color: var(--text-primary);
  background-color: var(--page-background);
  font-family: 'Open Sans', sans-serif;
}

button,
input {
  font: inherit;
}

.recipe-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.recipe-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e2e8f0;
}

.recipe-header h1 {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
}

.recipe-meta li {
  display: flex;
  gap: 0.3rem;
}

.recipe-meta-label {
  font-weight: 700;
}

.recipe-error {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid #ef4444;
  border-radius: 6px;
  color: #991b1b;
  background-color: #fef2f2;
}

.recipe-scroll-viewport {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 6px;
  -webkit-overflow-scrolling: touch;
}

.recipe-scroll-viewport:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.4);
  outline-offset: 3px;
}

.recipe-grid {
  display: grid;
  min-width: var(--grid-min-width);

  grid-template-columns:
    var(--ingredient-column-width)
    repeat(
      var(--recipe-column-count),
      minmax(var(--stage-column-width), 1fr)
    );

  grid-template-rows:
    repeat(var(--recipe-row-count), auto);

  gap: 1px;
  overflow: visible;
  border: 1px solid var(--border-medium);
  border-radius: 6px;
  background-color: var(--border-light);
}

.cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1rem;
  background-color: var(--surface-primary);
}

.cell-ingredient {
  position: sticky;
  left: 0;
  z-index: 10;
  justify-content: center;
  color: #334155;
  background-color: var(--surface-ingredient);
  font-weight: 500;
}

.cell-action {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background-color: var(--surface-secondary);
  transition:
    background-color 0.2s ease,
    opacity 0.2s ease,
    box-shadow 0.2s ease;
}

.cell-action:hover {
  box-shadow: inset 4px 0 0 var(--accent);
}

.cell-action:focus-visible {
  z-index: 2;
  outline: 3px solid rgba(37, 99, 235, 0.4);
  outline-offset: -3px;
}

.action-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.action-time {
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.action-title {
  margin-bottom: 0.5rem;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
}

.action-text {
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1.4;
}

.step-checkbox {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  cursor: pointer;
  accent-color: var(--accent);
}

.cell-action.step-done {
  opacity: 0.55;
  background-color: var(--page-background);
}

.cell-action.step-done .action-title,
.cell-action.step-done .action-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.cell-connector {
  position: relative;
  align-items: center;
  justify-content: center;
}

.cell-connector::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  border-bottom: 2px dashed var(--border-light);
}

.swipe-hint {
  display: none;
  margin-bottom: 0.75rem;
  padding: 0.6rem;
  border-radius: 4px;
  color: #ffffff;
  background-color: var(--accent);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

.swipe-hint-hidden {
  opacity: 0;
  transform: translateY(-5px);
}

.recipe-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.button {
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}

.button-secondary {
  border-color: var(--border-medium);
  color: #334155;
  background-color: var(--surface-primary);
}

.button-secondary:hover {
  background-color: var(--surface-secondary);
}

@media screen and (max-width: 999px) {
  body {
    padding: 1rem;
  }

  .swipe-hint {
    display: block;
  }

  .cell-ingredient::after {
    content: "";
    position: absolute;
    top: 0;
    right: -12px;
    width: 12px;
    height: 100%;
    pointer-events: none;
    background:
      linear-gradient(
        to right,
        rgba(0, 0, 0, 0.1),
        rgba(0, 0, 0, 0)
      );
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell-action,
  .swipe-hint {
    transition: none;
  }
}

/* ========================================================
   STEP TIMERS
   ======================================================== */

.step-timer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #cbd5e1;
}

.timer-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-direction: column;
}

.timer-display {
  color: #0f172a;
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.timer-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #475569;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  user-select: none;
}

.timer-mode-checkbox {
  margin: 0;
  accent-color: #1EADC3;
}

.timer-status {
  min-height: 1.1rem;
  margin-top: 0.35rem;
  color: #64748b;
  font-size: 0.7rem;
}

.timer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.timer-button {
  min-width: 58px;
  padding: 0.38rem 0.55rem;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  color: #334155;
  background-color: #ffffff;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
}

.timer-button:hover:not(:disabled) {
  border-color: #1EADC3;
  color: #1EADC3;
  background-color: #eff6ff;
}

.timer-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.timer-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.timer-start {
  border-color: #1EADC3;
  color: #ffffff;
  background-color: #1EADC3;
}

.timer-start:hover:not(:disabled) {
  color: #ffffff;
  background-color: #1EADC3;
}

.step-timer[data-timer-state="running"] {
  border-top-color: #1EADC3;
}

.step-timer[data-timer-state="running"]
.timer-display {
  color: #1EADC3;
}

.step-timer[data-timer-state="paused"]
.timer-display {
  color: #d97706;
}

.step-timer.timer-complete {
  border-top-color: #16a34a;
}

.step-timer.timer-complete
.timer-display {
  color: #15803d;
}

.step-timer.timer-complete
.timer-status {
  color: #15803d;
  font-weight: 700;
}
