/* ===========================
   Shift Calendar - styles
   Base tone matches tokens.css (Terracotta & Cream);
   accent overridden to mint/teal for this app.
   =========================== */

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

:root {
  color-scheme: light;

  /* Base tone (from tokens.css) */
  --bg: #FAF4EC;
  --card: #FFFFFF;
  --border: #EDE2D4;
  --divider: #F4EBDF;
  --ink: #3D3229;
  --text-2: #6B5F51;
  --muted: #8C7F70;
  --faint: #B5A794;
  --error: #C0392B;

  /* Off (neutral, cream-based) */
  --off-bg: #F4EBDF;
  --off-text: #6B5F51;

  /* Accent overridden to mint/teal for this app */
  --accent: #2E8F82;
  --accent-hover: #24756A;
  --accent-tint: #DEF2EF;
  --accent-line: #B7DDD7;

  --shadow-card: 0 2px 10px rgba(60, 40, 20, 0.06);
  --shadow-modal: 0 24px 60px rgba(60, 40, 20, 0.30);
  --modal-scrim: rgba(61, 50, 41, 0.40);
  --focus-ring: 0 0 0 3px rgba(46, 143, 130, 0.18);

  --radius-card: 20px;
  --radius-modal: 24px;
  --radius-pill: 999px;

  --font: "Nunito", sans-serif;
}

body {
  font-family: var(--font);
  margin: 0;
  padding: 40px 20px 64px;
  background: var(--bg);
  color: var(--ink);
}

header, main {
  max-width: 680px;
  margin: 0 auto;
}

header {
  margin-bottom: 24px;
}

header h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

header h1 .title-accent {
  color: var(--accent);
}

header p {
  color: var(--text-2);
  margin: 0;
  font-size: 14px;
}

/* Empty state */
.empty-state {
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  margin-bottom: 24px;
}

/* Calendar card */
.calendar-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.month-label {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  text-align: center;
  flex: 1;
}

.nav-btn {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  border: 1.5px solid var(--accent-line);
  background: var(--card);
  color: var(--accent-hover);
  border-radius: var(--radius-pill);
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--accent-tint);
}

.nav-btn:focus-visible,
.day-cell:focus-visible,
.choice-btn:focus-visible,
.status-btn:focus-visible,
.secondary-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.next-shift-text {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-hover);
  background: var(--accent-tint);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 0 16px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
  text-transform: uppercase;
  margin-bottom: 6px;
}

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

.day-cell {
  position: relative;
  font-family: var(--font);
  aspect-ratio: 1 / 1;
  width: 100%;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  overflow: hidden;
}

.day-num {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.day-preview {
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.5;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  box-sizing: border-box;
}

/* Positioned in the corner (not bottom-center) so it never collides
   with the .day-preview text line sitting at the bottom of the cell. */
.day-cell.day-has-memo::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.day-cell:hover:not(:disabled) {
  background: var(--divider);
}

.day-cell:disabled {
  cursor: default;
  color: var(--faint);
}

.day-cell.day-muted {
  color: var(--faint);
  opacity: 0.55;
}

.day-cell.day-past {
  color: var(--faint);
  opacity: 0.55;
}

.day-cell.day-work {
  background: var(--accent-tint);
  color: var(--accent-hover);
}

.day-cell.day-off {
  background: var(--off-bg);
  color: var(--off-text);
}

/* Next shift takes visual priority over plain work/off styling */
.day-cell.day-next {
  background: var(--accent);
  color: #fff;
}

/* Today is marked with a border only, never a background fill,
   so it never collides with the work/off/next state colors. */
.day-cell.day-today {
  border-color: var(--ink);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
  font-size: 12px;
  color: var(--text-2);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2px solid transparent;
}

.legend-work { background: var(--accent-tint); }
.legend-off { background: var(--off-bg); }
.legend-next { background: var(--accent); }
.legend-today { background: transparent; border-color: var(--ink); }
.legend-memo-dot {
  background: transparent;
  border: none;
  position: relative;
}
.legend-memo-dot::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.7;
}

/* Modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

/* The [hidden] attribute alone loses to the class's own "display: flex"
   above (same specificity, author rule wins), so it must be restated here
   with higher specificity to actually hide the modal. */
.modal-scrim[hidden] {
  display: none;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.modal-date {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 16px;
}

.status-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.status-btn {
  flex: 1;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 10px 12px;
  cursor: pointer;
  background: var(--card);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}

.status-btn:hover {
  background: var(--divider);
}

.status-btn.status-work.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.status-btn.status-off.active {
  background: var(--off-bg);
  color: var(--ink);
}

.time-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

/* Same [hidden]-vs-display cascade issue as .modal-scrim above. */
.time-fields[hidden] {
  display: none;
}

.time-field {
  flex: 1;
  text-align: left;
}

.time-field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-bottom: 4px;
}

.time-field input[type="time"] {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
}

.time-field input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.memo-field {
  text-align: left;
  margin-bottom: 16px;
}

.memo-field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-bottom: 4px;
}

.memo-field textarea {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  resize: vertical;
  min-height: 56px;
  box-sizing: border-box;
}

.memo-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.choice-btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  cursor: pointer;
  border: none;
}

.choice-btn.choice-work {
  background: var(--accent);
  color: #fff;
}

.choice-btn.choice-work:hover {
  background: var(--accent-hover);
}

.choice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.choice-btn.choice-clear {
  background: var(--card);
  color: var(--error);
  border: 1.5px solid var(--border);
}

.choice-btn.choice-clear:hover {
  background: var(--divider);
}

.secondary-btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  cursor: pointer;
  background: var(--card);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  width: 100%;
}

.secondary-btn:hover {
  background: var(--divider);
}

@media (max-width: 420px) {
  body {
    padding: 24px 12px 48px;
  }

  .day-cell {
    border-radius: 10px;
  }

  .day-num {
    font-size: 13px;
  }

  .day-preview {
    font-size: 7.5px;
  }

  .calendar-card {
    padding: 14px;
  }

  .calendar-grid {
    gap: 3px;
  }
}
