/* Owner: package P1 (Glass chrome, canvas and page shell (wordmark, brand menu, top bar, dock, idle fade, phone layout)). Clockface Online rebrand overrides, linked last in the index.php head. */

/* =====================================================================
   1. Wordmark: outline-clock mark + "Clockface Online" + Beta badge
   ===================================================================== */
.top-brand-mark {
  display: inline-block;
  flex-shrink: 0;
  align-self: center;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask: url(logo.png) center / contain no-repeat;
  mask: url(logo.png) center / contain no-repeat;
}
.top-brand.has-custom-brand .top-brand-mark { display: none; }

.top-brand .cfo-badge {
  align-self: center;
  text-shadow: none;
}

/* Classroom / Exam suffix: JS toggles its inline display, so only the look lives here */
#topBrandModeSuffix {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 22px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--on-glass);
}

@media (prefers-reduced-motion: reduce) {
  .top-brand:hover { transform: none; }
}

/* Phone: the mark and the badge only. The words stay for screen readers (clip, not display:none,
   so the [hidden] attribute JS sets for a custom logo keeps working). */
@media (max-width: 600px) {
  .top-brand #topBrandDefault,
  .top-brand #topBrandModeSuffix {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .top-brand-mark {
    width: 26px;
    height: 26px;
  }
}

/* =====================================================================
   2. Canvas tone: pale canvases get glass-dim under the chrome.
      body.cfo-canvas-light is toggled by cfoSyncCanvasState() in js/index.js
      and is shared with other packages (pinned quote, exam banner).
   ===================================================================== */
body.cfo-canvas-light .glass-nav {
  background: linear-gradient(var(--glass), var(--glass)), var(--glass-dim);
}
/* The bare wordmark gets a dim chip so white letters still read on a pale canvas */
body.cfo-canvas-light .top-brand:not(.has-custom-brand) {
  background: var(--glass-dim);
  padding: var(--space-1) var(--space-3);
  margin: calc(var(--space-1) * -1) calc(var(--space-3) * -1);
  border-radius: var(--radius-pill);
  text-shadow: none;
}
/* The wordmark's white focus ring sits 4px outside the chip (and a custom logo has no chip), so back it with a dim halo */
body.cfo-canvas-light .top-brand:focus-visible {
  box-shadow: 0 0 0 8px var(--glass-dim);
}

/* =====================================================================
   3. Corner brand menu (opened from the wordmark)
   ===================================================================== */
body #brandMenu {
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  padding: var(--space-2);
  gap: 2px;
  font-family: var(--font-sans);
  transform: translateY(-8px);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), visibility var(--dur-base) var(--ease);
}
body #brandMenu.show-popover { transform: translateY(0); }

body #brandMenu button,
body #brandMenu a {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  gap: var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background-color var(--dur-fast) var(--ease);
}
body #brandMenu button[hidden] { display: none; }
body #brandMenu button:hover,
body #brandMenu a:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
/* all: unset in style.css removed the ring, so put it back explicitly */
body #brandMenu button:focus-visible,
body #brandMenu a:focus-visible {
  background: var(--surface-hover);
  color: var(--text-primary);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}
body #brandMenu i {
  width: 16px;
  font-size: 16px;
  text-align: center;
  color: var(--primary-ink);
}
body #brandMenu span:not(.cfo-badge) { flex: 1; }
body #brandMenu .cfo-badge { flex: none; }
body #brandMenu .cfo-badge i {
  width: auto;
  font-size: 10px;
  color: inherit;
}
@media (prefers-reduced-motion: reduce) {
  body #brandMenu,
  body #brandMenu.show-popover { transform: none; }
}

/* =====================================================================
   4. Top bar extras: divider, avatar, notification count, promo badge
   ===================================================================== */
#topHeaderBar .nav-divider {
  width: 1px !important;
  min-width: 1px !important;
  height: 24px !important;
  background-color: var(--glass-border) !important;
  box-shadow: none !important;
  margin: 0 var(--space-1);
}

#navFeedback {
  cursor: pointer;
  position: relative;
}

/* "Get the app" stays off phone-width top bars: there it crowds a Plus custom corner logo, and
   iPhone Safari shows its own App Store banner (the profile menu has the item too). */
@media (max-width: 600px) {
  #topHeaderBar #navGetApp { display: none !important; }
}

/* Avatar: 32px circle with a glass edge; the initial sits in a <span> (was a <div>) */
#topHeaderBar .nav-avatar-link {
  width: 44px;
  height: 44px;
  flex-direction: row;
}
#topHeaderBar .nav-avatar-circle {
  width: 32px;
  height: 32px;
  margin: 0;
  border: 0;
  border-radius: var(--radius-pill);
  box-shadow: 0 0 0 2px var(--glass-border);
  transition: box-shadow var(--dur-fast) var(--ease);
}
#topHeaderBar .nav-avatar-link:hover .nav-avatar-circle,
#topHeaderBar .nav-avatar-link.active-glow .nav-avatar-circle {
  border-color: transparent;
  transform: none;
  box-shadow: 0 0 0 2px var(--on-glass);
}
.nav-avatar-circle > span {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}
@media (max-width: 600px) {
  #topHeaderBar .nav-avatar-circle {
    width: 28px;
    height: 28px;
    margin: 0;
  }
  .nav-avatar-circle > span { font-size: 12px; }
}

/* Unread notifications: the heartbeat toggles the inline display (flex/none) */
#navNotifBadge.nav-notif-badge {
  position: absolute;
  top: 2px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: var(--on-glass);
  border: 1px solid var(--glass-border);
  font-family: var(--font-sans);
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
  pointer-events: none;
}

/* Full screen works in narrow desktop windows too: only hide it on touch-first devices */
@media (max-width: 1024px) and (hover: hover) and (pointer: fine) {
  #topHeaderBar #navFullscreen { display: flex !important; }
}

/* =====================================================================
   5. Dock extras: sounds dot, reduced motion, drag-to-remove zone
   ===================================================================== */
.nav-sounds-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  box-shadow: none;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .bottom-app-dock a:hover,
  .bottom-app-dock a.dock-store-btn:hover,
  .dock-item:hover { transform: none; }
  .bottom-app-dock.dock-hidden { transform: translateX(-50%) !important; }
}

body #dockTrashZone {
  bottom: calc(85px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(var(--danger-tint), var(--danger-tint)), var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 1px dashed var(--danger);
  color: var(--danger);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease), background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
body #dockTrashZone i {
  font-size: 14px;
  color: inherit;
}
body #dockTrashZone.drag-over {
  background: linear-gradient(var(--danger-line), var(--danger-line)), var(--surface);
  border: 1px solid var(--danger);
  color: var(--danger);
  transform: translateX(-50%) translateY(-3px) scale(1.04);
  box-shadow: var(--shadow-float);
}
@media (prefers-reduced-motion: reduce) {
  body #dockTrashZone,
  body #dockTrashZone.active,
  body #dockTrashZone.drag-over { transform: translateX(-50%); }
  body #dockTrashZone.drag-over i { animation: none !important; }
}

/* =====================================================================
   6. Idle fade: keyboard focus inside the chrome keeps it visible
   ===================================================================== */
.top-header-bar.inactive-fade,
.bottom-app-dock.inactive-fade {
  transition: opacity var(--dur-base) var(--ease);
}
.glass-nav:not(.dock-hidden):focus-within {
  opacity: 1;
  pointer-events: auto;
}

/* =====================================================================
   7. Background colour swatches: selected state (design-system Swatch: 2px ring outside a
      2px surface gap). cfoSyncBgSwatches() sets .is-active and aria-pressed from the canvas.
   ===================================================================== */
#bgSwatches .swatch.is-active,
#bgSwatches .swatch[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px var(--text-primary-15), 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

/* =====================================================================
   8. Driver.js tutorial popover: paper card, navy title, pill buttons
   ===================================================================== */
.driver-popover {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  padding: var(--space-5) var(--space-6);
  font-family: var(--font-sans);
  max-width: 320px;
}
.driver-popover * { font-family: var(--font-sans); }
.driver-popover .driver-popover-title {
  font-size: 18px;
  line-height: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 var(--space-8) 0 0;
}
.driver-popover .driver-popover-description {
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: var(--space-2);
}
.driver-popover .driver-popover-footer {
  margin-top: var(--space-4);
  gap: var(--space-2);
}
.driver-popover .driver-popover-progress-text {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
}
.driver-popover .driver-popover-navigation-btns { gap: var(--space-2); }
.driver-popover .driver-popover-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  margin: 0;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--text-primary);
  text-shadow: none;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.driver-popover .driver-popover-footer button:hover { background: var(--surface-hover); }
.driver-popover .driver-popover-footer .driver-popover-next-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}
.driver-popover .driver-popover-footer .driver-popover-next-btn:hover {
  background: var(--primary);
  border-color: var(--primary-ink);
}
.driver-popover .driver-popover-footer button.driver-popover-btn-disabled {
  opacity: var(--disabled);
  cursor: default;
}
.driver-popover .driver-popover-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  top: var(--space-2);
  right: var(--space-2);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 20px;
  transition: background-color var(--dur-fast) var(--ease);
}
.driver-popover .driver-popover-close-btn:hover,
.driver-popover .driver-popover-close-btn:focus-visible {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.driver-popover .driver-popover-arrow-side-left { border-left-color: var(--surface); }
.driver-popover .driver-popover-arrow-side-right { border-right-color: var(--surface); }
.driver-popover .driver-popover-arrow-side-top { border-top-color: var(--surface); }
.driver-popover .driver-popover-arrow-side-bottom { border-bottom-color: var(--surface); }
