/* ============================================================
   CALENDAR ROOT + GLOBAL VARIABLES
   ============================================================ */
:root {
  --seg-height: 20px;
  --seg-radius: 4px;
  --seg-fontsize: 12px;

  /* Default speed palette colours for Calendar segments */
  --col-lowspeed: #16a34a;
  --col-midspeed: #ca8a04;
  --col-highspeed: #ea580c;
  --col-fast: #dc2626;
  --col-extreme: #7f1d1d;
  --col-neutral: #94a3b8;

  /* Layout geometry — overridden at runtime by renderCalendarScreen()
     injecting exact pixel values from the layout engine. These defaults
     prevent total collapse if the engine doesn't supply them. */
  --cell-width: 120px;
  --gutter: 4px;
}

/* Calendar container */
#calendarScreen {
  position: relative;
  overflow: auto;
  /*
  background: none;
  border: 1px solid #ccc;
  */
  touch-action: pinch-zoom;
  user-select: none;
  height: 300px;
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-row label {
  width: 120px;
  font-weight: 500;
}

.settings-row select {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.95rem;
}

/* ============================================================
   LAYOUT MODES (STRUCTURAL)
   ============================================================ */
.layout-autofit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.layout-compare {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  gap: 12px;
}

.layout-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   CALENDAR BLOCKS
   ============================================================ */
.cal-block {
  position: absolute;
  box-sizing: border-box;
  overflow: hidden;
  font-family: inherit;
}

/* Day label (Mon, Tue, etc.) */
.cal-dayLabel {
  font-weight: 600;
  text-align: center;
  background: var(--daylabel-bg, #fafafa);
  border-bottom: 1px solid #ddd;
  color: #0f172a;
}

/* Site header — width set by the layout engine to span 7 columns in
   week-grid mode, so text-align:center lands above Wednesday naturally */
.cal-siteHeader {
  font-weight: 700;
  text-align: center;
  background: var(--header-bg, #f0f4f8);
  border-bottom: 2px solid #bbb;
  color: #0f172a;
}

/* Global date-range header */
.cal-header {
  font-weight: 700;
  text-align: center;
  background: var(--header-bg, #e8eef4);
  border-bottom: 2px solid #aaa;
  color: #0f172a;
}

/* Month header */
.cal-monthHeader {
  font-weight: 600;
  text-align: center;
  background: var(--monthheader-bg, #f4f4f4);
  border-bottom: 1px solid #ccc;
  color: #0f172a;
}

/* Day cell — white background so it lifts off the pale blue gutter canvas */
.cal-daycell {
  background: white;
  color: #0f172a;
  padding: 2px 4px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.cal-daycell-header {
    display: flex;
    font-size: 11px;
    line-height: 1.2;
    margin-bottom: 4px;
	
	flex-direction: column; 
    gap: 2px; /* small vertical spacing between rows */
}
.cal-block-empty {
  /* Transparent — canvas pale blue shows through, same as gutters */
  background: none;
  border: none;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}
.cal-block-spacer {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background: none;
  border: none;
  pointer-events: none;
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.extra {
    white-space: nowrap;
    font-size: 11px; /* compact-friendly */
    line-height: 1.1;
}
.extras-left,
.extras-right {
    display: flex;
    gap: 6px;
    align-items: center;
}
.extras-left {
    justify-content: flex-start; /* explicit */
}
.extras-right {
    justify-content: flex-end;   /* FIX: right justify */
	width: 100%;                 /* ensures it spans full row width */
}
.extra .sun,
.extra .hwlw,
.extra .moon,
.extra .extreme {
    display: flex;
    gap: 6px;
    align-items: center;
}
.extra .extreme {
    color: #b00;
    font-weight: bold;
    font-size: 11px;
}
.extra.date {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  color: #00f;
}

/* (Bare .sun, .hwlw, .moon, .extreme selectors removed — use .extra .sun etc.
    to avoid accidentally overriding the scoped .extra versions above.) */



/* Slack cell container */
.cal-slack-cell {
  padding: 0px;
  display: flex;
  flex-direction: column;
}


/* ============================================================
   SLACK TRAFFIC BARS
   ============================================================ */
.slack-traffic {
  display: flex;
  
  height: var(--seg-height);
  /*
  // Month grid
  flex-direction: column;   / * ← vertical stack * /
  height: auto;             / * ← let it grow * /
  */
	  
  border-radius: var(--seg-radius);
  overflow: hidden;
  margin: 2px 0;
  
  gap: 2px;
	
  width: 100%;
}

.slack-traffic .seg {
  flex: 1;
  /*
  // Month Grid 
  flex: 0 0 var(--seg-height);   / * ← each segment gets full height * /
  height: var(--seg-height);     / * ← enforce height explicitly * /
  */
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--seg-fontsize);
  font-weight: 600;
  padding: 0 2px;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
}
.seg {
    padding: 1px 3px;
    border-radius: 3px;
    font-size: var(--seg-fontsize, 11px);
    line-height: 1.2;
    white-space: nowrap;
}

/* Container */
.day-extras-dropdown {
    position: relative;
    display: inline-block;
    font-size: 14px;
}

/* Button */
.day-extras-dropdown .dropdown-button {
    background: var(--panel-bg, #f0f8ff);
    border: 1px solid var(--panel-border, #bcd);
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-colour, #222);
    font-weight: 500;
}

/* Menu container */
.day-extras-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    background: var(--panel-bg, #f0f8ff);
    border: 1px solid var(--panel-border, #bcd);
    border-radius: 4px;
    padding: 8px 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 180px;
}

/* Show menu when parent has .open */
.day-extras-dropdown.open .dropdown-menu {
    display: block;
}

/* Checkbox labels */
.day-extras-dropdown .dropdown-menu label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    cursor: pointer;
    color: var(--text-colour, #222);
}

/* Checkbox styling (optional) */
.day-extras-dropdown input[type="checkbox"] {
    transform: scale(1.1);
}

/* ============================================================
   PALETTE INHERITANCE (from <body class="colour-xxx">)
   ============================================================ */

/* Slack segments always use the palette colour */
.slack-traffic .seg {
    background: var(--seg-colour);
    color: var(--seg-text, #000);
}

/* ============================================================
   COLOUR MODES (INTENSITY ONLY — DO NOT OVERRIDE PALETTE)
   ============================================================ */

/* Mode 0 — text only */
.colour-mode-0 .slack-traffic .seg,
.colour-mode-0 .seg {
    background: none;
    color: var(--seg-colour);
    border: none;
}

/* Mode 1 — 33% tint */
.colour-mode-1 .slack-traffic .seg,
.colour-mode-1 .seg {
    background: color-mix(in srgb, var(--seg-colour) 33%, white);
    color: #000;
}

/* Mode 2 — 67% tint */
.colour-mode-2 .slack-traffic .seg,
.colour-mode-2 .seg {
    background: color-mix(in srgb, var(--seg-colour) 67%, white);
    color: #000;
}

/* Mode 3 — full colour */
.colour-mode-3 .slack-traffic .seg,
.colour-mode-3 .seg {
    background: var(--seg-colour);
    color: #fff;
}

/* Mode 4 — full colour + bold */
.colour-mode-4 .slack-traffic .seg,
.colour-mode-4 .seg {
    background: var(--seg-colour);
    color: #fff;
    font-weight: bold;
}

/* ============================================================
   CALENDAR SCROLL + CANVAS
   In week mode: a sticky header strip sits above the body canvas
   inside the scroll container. Both are the same totalWidth so
   horizontal scroll moves them in lockstep.
   ============================================================ */

.calendar-scroll-x {
  overflow-x: auto;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  -webkit-overflow-scrolling: touch;
  background: var(--calendar-gutter-bg, #ddeeff);
}

/* Sticky header strip — siteHeader + dayLabel blocks live here.
   position:sticky inside an overflow:auto ancestor works because
   the strip is in normal flow; the canvas below it scrolls away. */
.calendar-sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--calendar-gutter-bg, #ddeeff);
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
  /* width and height set by JS to match layout.totalWidth / headerH */
  /* Must not clip resize handles at column right-edges */
  overflow: visible;
}

/* Body canvas — pale blue background shows through gutters between cells */
.calendar-canvas {
  position: relative;
  background: var(--calendar-gutter-bg, #ddeeff);
}

/* Transparent spacer for empty cells — single definition */
.cal-block-spacer {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  pointer-events: none;
}

/* Remove redundant plain selectors that were accidentally duplicating
   the .extra-scoped versions and could override them unexpectedly. */
/* ============================================================
   COLUMN RESIZE HANDLES
   Injected into the sticky header by the renderer.
   A faint border is always visible so the handle is
   discoverable; it intensifies on hover and during drag.
   ============================================================ */
.cal-siteHeader, .cal-dayLabel {
    overflow: visible;
}

.cal-col-resize-handle {
    position: absolute;
    top: 0;
    right: -4px; /* Centered on the column boundary */
    height: 100%;
    width: 8px;
    cursor: col-resize;
    z-index: 200;
    background: transparent;
    user-select: none;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.cal-col-resize-handle::after {
    content: "";
    position: absolute;
    top: 0;
    left: 3px; /* Centered within the 8px width */
    width: 2px;
    height: 100%;
    background: rgba(0, 0, 0, 0.15); /* Faint line always visible */
    transition: background-color 0.2s ease, width 0.2s ease, left 0.2s ease;
}

.cal-col-resize-handle:hover::after {
    background: rgba(0, 80, 200, 0.7); /* Darker blue line on hover */
    width: 3px;
    left: 2px;
}

.cal-col-resize-handle:hover {
    background: rgba(0, 80, 200, 0.1); /* Subtle blue background overlay */
}

.cal-col-resize-handle:active::after {
    background: rgba(0, 80, 200, 1); /* Bright solid blue line on drag */
    width: 3px;
    left: 2px;
}

/* Column resize: cursor and drag-line are applied inline by calendarRenderer.js */