/** @format */

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

:root {
  --bg: #eef1f7;
  --bg-accent: #e4e9f5;
  --surface: #ffffff;
  --text: #1c2130;
  --muted: #6b7280;
  --border: rgba(28, 33, 48, 0.08);
  --shadow: 0 12px 30px rgba(28, 33, 48, 0.08);
  --bar-height: 44px;
  --bar-margin: 28px;
  --bar-radius: 8px;
  --radius-lg: 18px;
  --radius-md: 12px;

  --accent-default: #4f46e5;
  --accent-yellow: #d97706;
  --accent-cyan: #0891b2;
  --accent-green: #16a34a;
  --accent-magenta: #c026d3;
  --accent-red: #dc2626;
  --accent-blue: #2563eb;

  --gradient-height: 100svh;
  --strip-overshoot: 60px;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-accent);
  color: var(--text);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Viewport-fixed layer so the gradient spans the screen once instead of
   repeating down tall pages. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--gradient-height);
  z-index: -1;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

#app {
  /* position: relative no longer needed for the strip, but harmless */
  position: relative;
  width: 100%;
  min-height: 100svh;
}

/* Full-screen splash shown until the app has mounted its first page */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 40px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent-default);
  animation: loading-spin 0.8s linear infinite;
}

.loading-text {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------------------
   Single fixed top layer: the ONLY viewport-fixed element in the header.
   The strip and the bar are absolute inside it, so they can never drift
   apart — whatever iOS does to this one box, it does to both children.
   -------------------------------------------------------------------------- */
.top-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(
    var(--bar-height) + var(--bar-margin) + env(safe-area-inset-top, 0px)
  );
  z-index: 9;
  /* Clicks pass through to the page; .waybar re-enables them for itself */
  pointer-events: none;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

/* Opaque strip behind the bar. Extends above the viewport top by the
   overshoot so a downward iOS displacement can't expose a gap, and is
   phase-aligned with body::before's gradient. */
.top-layer__strip {
  position: absolute;
  inset: calc(-1 * var(--strip-overshoot)) 0 0 0;
  z-index: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%) 0
    var(--strip-overshoot) / 100% var(--gradient-height) no-repeat;
}

/* Floating waybar-style top bar */
.waybar {
  /* Absolute inside .top-layer — NOT fixed */
  position: absolute;
  top: calc(var(--bar-margin) + env(safe-area-inset-top, 0px));
  left: var(--bar-margin);
  right: var(--bar-margin);
  height: var(--bar-height);
  z-index: 1;
  background: var(--surface);
  border-radius: var(--bar-radius);
  box-shadow: var(--shadow);
  /* Re-enable interaction, which .top-layer disabled */
  pointer-events: auto;
}

/* Dim slightly when idle on devices with a real pointer; touch devices stay fully visible */
@media (hover: hover) and (pointer: fine) {
  .waybar {
    filter: brightness(0.92) saturate(0.85);
    transition: filter 0.2s ease;
  }

  .waybar:hover,
  .waybar:focus-within {
    filter: none;
  }
}

.waybar-inner {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}

.waybar-tray {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.waybar-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: 0.02em;
  flex: none;
}

.waybar-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.waybar-link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.waybar-link:hover {
  background: rgba(28, 33, 48, 0.06);
  color: var(--text);
}

.waybar-link.active {
  background: var(--accent-default);
  color: #ffffff;
}

/* Animated hamburger / close icon for the small-screen link dropdown */
.waybar-menu-toggle {
  display: none;
  position: relative;
  flex: none;
  width: 20px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.waybar-menu-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--muted);
  transform-origin: center;
}

.waybar-menu-line:nth-child(1) {
  top: 0;
}
.waybar-menu-line:nth-child(2) {
  top: 6px;
}
.waybar-menu-line:nth-child(3) {
  top: 12px;
}

.waybar-menu-toggle:hover .waybar-menu-line {
  background: var(--text);
}

.waybar-socials {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.waybar-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 5px;
  border-radius: var(--radius-md);
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease;
}

.waybar-social:hover {
  background: rgba(28, 33, 48, 0.06);
}

.waybar-social-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  display: block;
}

/* Scrollable page content */
.content {
  box-sizing: border-box;
  width: 100%;
  min-height: 100svh;
  padding: calc(
      var(--bar-height) + var(--bar-margin) * 2 + env(safe-area-inset-top, 0px)
    )
    20px 60px;
  /* removed — see Fix 1 notes */
  /* overflow-y: auto; */
}

.page {
  max-width: 720px;
  margin: 0 auto;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}

.section-heading {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 28px 0 12px;
}

.page-paragraph {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 14px;
}

.page-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.entry-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.entry-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 16px;
}

.page-image {
  margin: 0 0 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-accent);
}

.page-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.page-image figcaption {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface);
}

.page-gallery {
  display: grid;
  grid-template-columns: repeat(var(--gallery-columns, 2), 1fr);
  gap: 12px;
  margin: 0 0 16px;
}

.page-gallery .page-image {
  margin: 0;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #ffffff;
  background: var(--accent-default);
  box-shadow: 0 4px 12px rgba(28, 33, 48, 0.12);
  transition: transform 0.15s ease;
}

.page-link:hover {
  transform: translateY(-1px);
}

.page-link.accent-default {
  background: var(--accent-default);
}
.page-link.accent-yellow {
  background: var(--accent-yellow);
}
.page-link.accent-cyan {
  background: var(--accent-cyan);
}
.page-link.accent-green {
  background: var(--accent-green);
}
.page-link.accent-magenta {
  background: var(--accent-magenta);
}
.page-link.accent-red {
  background: var(--accent-red);
}
.page-link.accent-blue {
  background: var(--accent-blue);
}

.accent-yellow-text {
  color: var(--accent-yellow);
}
.accent-cyan-text {
  color: var(--accent-cyan);
}

/* Small-screen layout. Driven by TopBar toggling .is-compact on <html> rather
   than a plain media query, so JS and CSS agree on exactly one breakpoint. */
:root.is-compact {
  --bar-margin: 14px;
}

.is-compact .waybar-menu-toggle {
  display: block;
}

.is-compact .waybar-links {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 14px;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 200px;
}

.is-compact .waybar-links.open {
  display: flex;
}

.is-compact .waybar-link {
  width: 100%;
  text-align: left;
}

.is-compact .waybar-socials {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 6px;
  border-right: 1px solid var(--border);
}
