/* Gatecal components. Every value comes from tokens.css (generated from tokens.json); class prefix gc-. */

.gc-root {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 24px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.gc-root *, .gc-root *::before, .gc-root *::after { box-sizing: border-box; }
.gc-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.gc-stack { display: grid; gap: var(--space-4); }

/* ---------- Button ---------- */
.gc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font: 500 15px/24px var(--font-sans);
  padding: 8px var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;
}
.gc-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gc-btn--primary { background: var(--accent); color: var(--on-accent); }
.gc-btn--primary:hover { background: var(--accent-hover); }
.gc-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.gc-btn--secondary:hover { background: var(--surface-sunken); }
.gc-btn--ghost { background: transparent; color: var(--accent-text); }
.gc-btn--ghost:hover { background: var(--accent-weak); }
.gc-btn--danger { background: var(--danger-weak); color: var(--danger); }
.gc-btn--danger:hover { border-color: var(--danger); }
.gc-btn--sm { font-size: 13px; line-height: 20px; padding: 4px var(--space-3); }
.gc-btn[disabled], .gc-btn[aria-disabled="true"] {
  background: var(--surface-sunken); color: var(--text-subtle); border-color: var(--line); cursor: not-allowed;
}
.gc-btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Text field ---------- */
.gc-field { display: grid; gap: 6px; min-width: 0; }
.gc-field__label {
  font: 600 12px/16px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
}
.gc-field__hint { font: 400 13px/20px var(--font-sans); color: var(--text-muted); }
.gc-input, .gc-input-group {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
}
.gc-input { font: 400 15px/22px var(--font-sans); padding: 8px var(--space-3); }
.gc-input::placeholder { color: var(--text-subtle); }
.gc-input:focus-visible, .gc-input-group:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.gc-input-group { display: flex; align-items: stretch; overflow: hidden; }
.gc-input-group__prefix {
  display: flex; align-items: center; padding: 0 var(--space-1) 0 var(--space-3);
  font: 400 13px/20px var(--font-mono); color: var(--text-muted); background: var(--surface-sunken);
  border-right: 1px solid var(--line);
  padding-right: var(--space-2);
}
.gc-input-group .gc-input { border: 0; border-radius: 0; outline: none; font-family: var(--font-mono); font-size: 14px; min-width: 0; }
.gc-field--error .gc-input, .gc-field--error .gc-input-group { border-color: var(--danger); }
.gc-field--error .gc-field__hint { color: var(--danger); }

/* ---------- Toggle ---------- */
.gc-toggle {
  position: relative; flex: none;
  width: 40px; height: 24px; padding: 0;
  border: 0; border-radius: var(--radius-pill);
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color 150ms ease-out;
}
.gc-toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform 150ms ease-out;
}
.gc-toggle[aria-checked="true"] { background: var(--accent); }
.gc-toggle[aria-checked="true"]::after { transform: translateX(16px); background: var(--on-accent); }
.gc-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gc-toggle-label { display: inline-flex; align-items: center; gap: var(--space-3); font: 400 15px/24px var(--font-sans); color: var(--text); }

/* ---------- Status badge ---------- */
.gc-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font: 600 12px/16px var(--font-sans);
  white-space: nowrap;
}
.gc-badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; flex: none; }
.gc-badge--synced { color: var(--success); background: var(--success-weak); }
.gc-badge--busy { color: var(--accent-text); background: var(--accent-weak); }
.gc-badge--skipped { color: var(--warning); background: var(--warning-weak); }
.gc-badge--syncing { color: var(--text-muted); background: var(--surface-sunken); }
.gc-badge--syncing::before { animation: gc-pulse 1.2s ease-in-out infinite; }
.gc-badge--error { color: var(--danger); background: var(--danger-weak); }
@keyframes gc-pulse { 50% { opacity: 0.25; } }

/* ---------- Calendar chip ---------- */
.gc-chip {
  --chip-color: var(--source-1);
  display: inline-flex; align-items: center; gap: var(--space-2);
  max-width: 100%;
  padding: 3px 10px 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: 500 13px/20px var(--font-sans); color: var(--text);
}
.gc-chip__swatch { width: 12px; height: 12px; border-radius: var(--radius-xs); background: var(--chip-color); flex: none; }
.gc-chip__account { font-weight: 400; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Rule list ---------- */
.gc-rules { display: grid; gap: var(--space-3); min-width: 0; }
.gc-rules__head { display: grid; gap: var(--space-1); }
.gc-rules__sync { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--text-muted); }
.gc-rules__hint { margin: 0; font: 400 13px/20px var(--font-sans); color: var(--text-muted); }
.gc-rules__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); counter-reset: gc-rule; }
.gc-rules__add { justify-self: start; }
.gc-rules template { display: none; }
.gc-rule {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: start; gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.gc-rule__num {
  display: grid; place-items: center; width: 28px; height: 28px; margin-top: 4px;
  border-radius: var(--radius-sm); background: var(--surface-sunken);
  font: 500 13px/1 var(--font-mono); color: var(--text-muted);
}
.gc-rules__list .gc-rule__num::before { counter-increment: gc-rule; content: counter(gc-rule); }
.gc-rule__num svg { width: 16px; height: 16px; }
.gc-rule__text { margin: 0; font: 400 15px/36px var(--font-sans); color: var(--text-muted); overflow-wrap: anywhere; }
.gc-rule__word {
  height: 30px; min-width: 4ch; max-width: 100%; field-sizing: content; vertical-align: middle;
  padding: 0 var(--space-2); margin: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: 500 14px/1 var(--font-mono);
}
.gc-rule__word:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* ", titled [Busy]": the title of a copy whose details are hidden; shown only while the action is "hide details" */
.gc-rule__titled { display: none; }
.gc-rule__text:has(.gc-pick[data-value="busy"]:is([data-role="action"], [data-role="other"])) .gc-rule__titled { display: inline; }
.gc-rule__tools { display: flex; gap: 2px; margin-top: 4px; }
.gc-rule__tool {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-subtle); cursor: pointer;
}
.gc-rule__tool svg { width: 16px; height: 16px; }
.gc-rule__tool:hover { background: var(--surface-sunken); color: var(--text); }
.gc-rule__tool:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.gc-rules__list > :first-child [data-gc="up"], .gc-rules__list > :last-child [data-gc="down"] { visibility: hidden; }
.gc-rule--else { grid-template-columns: 28px minmax(0, 1fr); background: var(--surface-sunken); border-style: dashed; box-shadow: none; }
.gc-rule--else .gc-rule__num { background: transparent; }
/* with no rules above it, the last row covers every event */
.gc-rule__else-all { display: none; }
.gc-rules:not(:has(.gc-rules__list > .gc-rule)) .gc-rule__else-some { display: none; }
.gc-rules:not(:has(.gc-rules__list > .gc-rule)) .gc-rule__else-all { display: inline; }
/* "For all events: skip it" would copy nothing, so it is offered only once a rule sits above */
.gc-rules:not(:has(.gc-rules__list > .gc-rule)) .gc-rule--else .gc-pick__opt[data-value="skip"] { display: none; }
@media (max-width: 520px) {
  .gc-rule { grid-template-columns: 28px minmax(0, 1fr); }
  .gc-rule__tools { grid-column: 2; justify-self: end; margin-top: 0; }
}

/* a choice inside a sentence */
.gc-pick { position: relative; display: inline-block; vertical-align: middle; line-height: normal; }
.gc-pick__btn {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px 0 10px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--accent-weak); color: var(--accent-text);
  font: 600 15px/1 var(--font-sans); cursor: pointer; white-space: nowrap;
}
.gc-pick__btn svg { width: 16px; height: 16px; transition: transform 120ms ease-out; }
.gc-pick__btn:hover { box-shadow: inset 0 0 0 1px currentColor; }
.gc-pick__btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gc-pick__btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.gc-pick--skip .gc-pick__btn { background: var(--warning-weak); color: var(--warning); }
.gc-pick--pass .gc-pick__btn { background: var(--success-weak); color: var(--success); }
.gc-pick__menu {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%;
  display: block; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-2);
}
.gc-pick__menu[hidden] { display: none; }
.gc-pick__opt { display: block; padding: 6px var(--space-3); border-radius: var(--radius-sm); font: 400 15px/24px var(--font-sans); color: var(--text); white-space: nowrap; cursor: pointer; }
.gc-pick__opt:hover, .gc-pick__opt:focus { background: var(--surface-sunken); outline: none; }
.gc-pick__opt[aria-selected="true"] { font-weight: 600; color: var(--accent-text); }

/* ---------- Event block ---------- */
.gc-event {
  --event-color: var(--source-1);
  position: relative;
  display: grid; gap: 2px; align-content: start;
  min-height: 48px; min-width: 0;
  padding: 6px var(--space-2) 6px 10px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--event-color) 16%, var(--surface));
  color: var(--text);
  overflow: hidden;
}
.gc-event::before { /* the post: a 3px bar in the calendar's colour, inset so it reads as part of the block */
  content: ""; position: absolute; left: 3px; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--event-color);
}
.gc-event__title { font: 600 13px/18px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-event__time { font: 500 12px/16px var(--font-mono); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.gc-event__via { font: 500 12px/16px var(--font-sans); color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.gc-event--copy {
  background: var(--surface);
  outline: 1.5px dashed var(--event-color); outline-offset: -1.5px;
}
.gc-event--busy {
  background: repeating-linear-gradient(135deg, var(--surface-sunken) 0 6px, var(--surface) 6px 12px);
  outline: 1px solid var(--line-strong); outline-offset: -1px;
}
.gc-event--busy::before { background: var(--line-strong); }
.gc-event--skipped {
  background: transparent; color: var(--text-muted);
  outline: 1px dashed var(--line-strong); outline-offset: -1px;
}
.gc-event--skipped::before { background: var(--warning); }
.gc-event--skipped .gc-event__title { text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---------- Booking link ---------- */
.gc-link {
  display: flex; align-items: center; gap: var(--space-3);
  max-width: 100%;
  padding: 6px 6px 6px var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.gc-link__url { flex: 1; min-width: 0; font: 400 14px/20px var(--font-mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-link__url b { font-weight: 500; color: var(--accent-text); }

@media (prefers-reduced-motion: reduce) {
  .gc-btn, .gc-toggle, .gc-toggle::after, .gc-pick__btn svg { transition: none; }
  .gc-badge--syncing::before { animation: none; }
}
