/* Week grid: day headers, time gutter, ruled day columns, now-line.
   Entries on the grid are styled in entries.css. */
.calendar-error { margin: 0 1.5rem 0.5rem; }

.calendar {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 1.5rem 1.5rem;
  background: var(--sheet);
  border: 1px solid var(--border);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--primary) 35%, transparent);
  min-height: 0;
}

.calendar-header {
  display: grid;
  grid-template-columns: var(--gutter-width) repeat(7, 1fr);
  border-bottom: 1px solid var(--accent);
  overflow-y: hidden;
  scrollbar-gutter: stable; /* keep columns aligned with the scrolling body */
}

.calendar-header > :first-child { border-right: 2px solid var(--margin); }

.day-header {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.6rem 0.6rem 0.4rem;
  border-left: 1px dotted var(--border);
}
.calendar-header > :nth-child(2) { border-left: none; }
.day-header .date {
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
}
.day-header .dow {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-transform: lowercase;
  color: var(--text-soft);
}
.day-header.today .date {
  /* highlighter swipe behind the number */
  background: linear-gradient(to top, var(--highlight) 55%, transparent 55%);
  padding: 0 0.15em;
}
.day-header.today .dow { color: var(--text); font-weight: 700; }

.calendar-body {
  flex: 1;
  display: flex;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-color: var(--rule) transparent;
  position: relative;
}

.time-gutter {
  width: var(--gutter-width);
  flex-shrink: 0;
  height: calc(var(--hour-height) * 24);
  border-right: 2px solid var(--margin);
}
.time-label {
  height: var(--hour-height);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-soft);
  text-align: right;
  padding-right: 8px;
  transform: translateY(-0.55em);
}
.time-label:first-child { visibility: hidden; }

.days {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.day-column {
  position: relative;
  border-left: 1px dotted var(--border);
  height: calc(var(--hour-height) * 24);
  /* ruled lines every hour, fainter at the half hour */
  background-image:
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule-faint) 1px, transparent 1px);
  background-size: 100% var(--hour-height), 100% calc(var(--hour-height) / 2);
  cursor: cell;
}
.day-column:first-child { border-left: none; }
.day-column.today { background-color: color-mix(in srgb, var(--primary) 12%, transparent); }
.day-column:hover { background-color: color-mix(in srgb, var(--accent) 6%, transparent); }
.day-column.today:hover { background-color: color-mix(in srgb, var(--primary) 18%, transparent); }

.now-line {
  position: absolute;
  top: calc(var(--hour-height) * var(--start) / 60);
  left: 0;
  right: 0;
  border-top: 2px dashed var(--secondary);
  z-index: 10;
  pointer-events: none;
}
.now-line::before {
  content: "now";
  position: absolute;
  right: 3px;
  top: -1.1em;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--secondary);
}

/* Small screens (keep the breakpoint in sync across files) */
@media (max-width: 760px) {
  .day-header { flex-direction: column; align-items: center; gap: 0; padding: 0.4rem 0; }
  .day-header .date { font-size: 1.2rem; }
  .calendar { margin: 0 0.5rem 0.5rem; }
}
