@font-face {
  font-family: 'Perfectly Nineties';
  src: url('../assets/fonts/PerfectlyNineties-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-display: 'Perfectly Nineties', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --bg-page: #000000;
  --bg-grid: #050505;
  --grid-dot: rgba(255, 255, 255, 0.12);
  --text-primary: #ffffff;
  --text-primary-soft: rgba(255, 255, 255, 0.92);
  --text-muted: rgba(255, 255, 255, 0.7);
  --text-faint: rgba(255, 255, 255, 0.45);
  --icon-invert: 1;
  --hover-tint: rgba(255, 255, 255, 0.06);

  --toolbar-bg: rgba(24, 24, 24, 0.9);
  --toolbar-border: rgba(255, 255, 255, 0.08);
  --toolbar-icon: rgba(255, 255, 255, 0.85);
  --toolbar-icon-active-bg: rgba(255, 255, 255, 0.14);
  --toolbar-divider: rgba(255, 255, 255, 0.15);

  /* Counteracts the smaller default canvas zoom on tablet/mobile (see
     defaultScaleForViewport in script.js) so text renders at the same
     on-screen size as the 100% desktop view, instead of shrinking with it. */
  --text-scale: 1;

  /* Kept in sync with the canvas's own zoom (view.scale) by applyTransform()
     in script.js, so annotation elements (captions, size badges) can counter
     -scale themselves and stay a constant on-screen size regardless of zoom. */
  --zoom-scale: 1;
}

[data-theme="light"] {
  --bg-page: #ffffff;
  --bg-grid: #f4f4f4;
  --grid-dot: rgba(0, 0, 0, 0.12);
  --text-primary: #0a0a0a;
  --text-primary-soft: rgba(10, 10, 10, 0.85);
  --text-muted: rgba(10, 10, 10, 0.65);
  --text-faint: rgba(10, 10, 10, 0.45);
  --icon-invert: 0;
  --hover-tint: rgba(0, 0, 0, 0.05);

  --toolbar-bg: rgba(255, 255, 255, 0.92);
  --toolbar-border: rgba(0, 0, 0, 0.08);
  --toolbar-icon: rgba(10, 10, 10, 0.8);
  --toolbar-icon-active-bg: rgba(0, 0, 0, 0.08);
  --toolbar-divider: rgba(0, 0, 0, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  /* Disables Safari/Chrome-iOS's automatic text-size inflation (both run on
     WebKit, which boosts font-size per element based on its own container
     width) — without this, our identically-sized captions render at visibly
     different sizes depending on how wide the frame they're attached to is. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  opacity: 0;
  transition: opacity 0.35s ease;
}

body.ready {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }
}

body.is-dragging {
  user-select: none;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Canvas ---------- */

.canvas-viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: default;
  touch-action: none;
}

.canvas-viewport.panning {
  cursor: grabbing;
}

.canvas-viewport.space-pan {
  cursor: grab;
}

.canvas-viewport.space-pan .frame {
  cursor: grab;
}

.canvas-grid {
  position: fixed;
  inset: 0;
  background-color: var(--bg-grid);
  pointer-events: none;
  transition: background-color 0.2s ease;
}

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.frame {
  position: absolute;
  top: 0;
  left: 0;
  cursor: grab;
}

.frame.dragging {
  cursor: grabbing;
  z-index: 1000;
}

/* ---------- Toolbar ---------- */

.toolbar {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: var(--toolbar-bg);
  border: 1px solid var(--toolbar-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.125);
  backdrop-filter: blur(8px);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--toolbar-icon);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
}

.toolbar-btn:hover,
.toolbar-btn.is-active {
  background: var(--toolbar-icon-active-bg);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--toolbar-divider);
  margin: 0 2px;
}

.toolbar-zoom-wrap {
  position: relative;
  display: flex;
}

.toolbar-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--toolbar-icon);
  font-family: var(--font-body);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.toolbar-zoom:hover {
  background: var(--toolbar-icon-active-bg);
}

.toolbar-zoom svg {
  width: 12px;
  height: 12px;
}

.zoom-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 140px;
  padding: 6px;
  border-radius: 10px;
  background: var(--toolbar-bg);
  border: 1px solid var(--toolbar-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.zoom-menu[hidden] {
  display: none;
}

.zoom-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.zoom-menu-item:hover {
  background: var(--toolbar-icon-active-bg);
}

.zoom-menu-shortcut {
  color: var(--text-faint);
  font-size: 12px;
}

.zoom-menu-divider {
  height: 1px;
  margin: 4px 2px;
  background: var(--toolbar-divider);
}

/* ---------- Intro frame ---------- */

/* Explicit width, not shrink-to-fit — .canvas has zero intrinsic width
   (every .frame child is absolutely positioned), so a frame relying on
   shrink-to-fit sizing against it gets miscomputed narrower than its
   content actually needs. */
.frame-picture {
  width: calc(76px * var(--text-scale));
}

.frame-intro {
  width: 827px;
  text-align: left;
}

.intro-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(40px * var(--text-scale));
  max-width: 827px;
}

.profile-pic {
  width: calc(76px * var(--text-scale));
  height: calc(76px * var(--text-scale));
  border-radius: 50%;
  object-fit: cover;
  -webkit-user-drag: none;
  user-drag: none;
}

.intro-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 60px;
  line-height: 1.15;
  color: var(--text-primary);
}

.intro-subtitle {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 60px;
  line-height: 1.1;
  color: var(--text-primary-soft);
}

.intro-subtitle .underline {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: var(--text-faint);
  transition: opacity 0.15s ease;
}

.intro-subtitle .underline:hover {
  opacity: 0.7;
}

/* ---------- Media frames ---------- */

/* Explicit width, not shrink-to-fit — a shrink-to-fit .frame with a
   width:100% child (the caption) treats that percentage as auto during
   sizing, so the caption renders at its own natural content width instead
   of clamping to the frame and never actually triggers its ellipsis. */
.frame-media {
  width: 800px;
}

.media-frame {
  position: relative;
  width: 800px;
}

.section-bg-img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  object-fit: contain;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 1.1s cubic-bezier(0.22, 1, 0.36, 1), transform 1.6s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-user-drag: none;
  user-drag: none;
}

iframe.section-bg-img {
  aspect-ratio: 16 / 9;
  pointer-events: none;
}

.section-bg-img.in-view {
  opacity: 1;
  transform: scale(1);
}

.media-caption,
.frame-caption {
  display: block;
  /* Matches the frame's own width and truncates with an ellipsis instead of
     overflowing or wrapping — a single-line block is what lets text-overflow
     work here, so the pieces below (link, dots, spans) are plain inline
     content rather than flex items. */
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Scaling font-size/margin directly (rather than a paint-only
     transform: scale()) keeps them a constant on-screen size as the canvas
     zooms out AND grows their real layout footprint to match — a transform
     wouldn't reserve the extra space, letting the frame below creep up and
     overlap the now visually-larger caption. */
  margin-bottom: calc(10px * var(--text-scale) / var(--zoom-scale));
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: calc(13px * var(--text-scale) / var(--zoom-scale));
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.media-caption-company {
  color: inherit;
  font-weight: 600;
}

.frame:has(.frame-object:hover) .media-caption,
.frame:has(.frame-object:hover) .frame-caption {
  color: #0d99ff;
}

.frame.selected .media-caption,
.frame.selected .frame-caption,
.frame.dragging .media-caption,
.frame.dragging .frame-caption {
  color: #0d99ff;
}

/* The outer .frame is what gets selected/dragged, but the outline, resize
   handles, and size badge visually belong to the .frame-object inside it
   (the caption above sits outside that box, same as a video's caption). */
.frame-object {
  position: relative;
  margin-bottom: calc(32px * var(--text-scale));
}

.frame.selected .frame-object,
.frame.dragging .frame-object {
  outline-color: #0d99ff;
}

.frame.selected .frame-object .handle,
.frame.dragging .frame-object .handle {
  opacity: 1;
}

.frame.selected .frame-object .size-badge,
.frame.dragging .frame-object .size-badge {
  opacity: 1;
}

/* ---------- Figma-style select outline ---------- */

.hover-select {
  outline: 2px solid transparent;
  outline-offset: 0px;
  transition: outline-color 0.15s ease;
}

.hover-select:hover,
.hover-select.selected,
.hover-select.dragging {
  outline-color: #0d99ff;
}

.hover-select.selected .handle,
.hover-select.dragging .handle {
  opacity: 1;
}

.handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #ffffff;
  border: 1.5px solid #0d99ff;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 1;
}

.handle-tl { top: -4px; left: -4px; }
.handle-tm { top: -4px; left: 50%; transform: translateX(-50%); }
.handle-tr { top: -4px; right: -4px; }
.handle-ml { top: 50%; left: -4px; transform: translateY(-50%); }
.handle-mr { top: 50%; right: -4px; transform: translateY(-50%); }
.handle-bl { bottom: -4px; left: -4px; }
.handle-bm { bottom: -4px; left: 50%; transform: translateX(-50%); }
.handle-br { bottom: -4px; right: -4px; }

.size-badge {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: calc(8px / var(--zoom-scale));
  padding: calc(3px / var(--zoom-scale)) calc(8px / var(--zoom-scale));
  border-radius: calc(4px / var(--zoom-scale));
  background: #0d99ff;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: calc(11px / var(--zoom-scale));
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 1;
}

/* ---------- Rulers ---------- */

.ruler {
  position: fixed;
  background: var(--toolbar-bg);
  transition: background-color 0.2s ease;
}

.ruler-h {
  top: 0;
  left: 0;
  right: 0;
  height: 24px;
  z-index: 900;
}

.ruler-v {
  top: 0;
  left: 0;
  bottom: 0;
  width: 24px;
  z-index: 901;
}

.ruler-corner {
  position: fixed;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  background: var(--toolbar-bg);
  border-right: 1px solid var(--toolbar-border);
  border-bottom: 1px solid var(--toolbar-border);
  z-index: 902;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* ---------- Custom cursor tag ---------- */

.cursor-tag {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 890;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  transform-origin: top left;
}

.cursor-tag.is-active {
  opacity: 1;
}

.cursor-tag-inner {
  display: flex;
  align-items: flex-start;
  animation: cursor-idle-drift 3.4s ease-in-out infinite;
}

@keyframes cursor-idle-drift {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(3px, -3px); }
  50% { transform: translate(-2px, 2px); }
  75% { transform: translate(2px, 3px); }
}

@media (prefers-reduced-motion: reduce) {
  .cursor-tag-inner {
    animation: none;
  }
}

.cursor-tag-arrow {
  display: block;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.cursor-tag-bubble {
  margin-left: -3px;
  margin-top: 16px;
  max-width: min(360px, 55vw);
  padding: 0.5rem 0.85rem;
  border-radius: 10px 10px 10px 2px;
  background: var(--cursor-color, #111111);
  color: var(--cursor-text-color, #ffffff);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.cursor-tag-caret {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-left: 1px;
  vertical-align: -0.1em;
  background: currentColor;
  animation: caret-blink 0.9s steps(1, start) infinite;
}

.cursor-tag-caret.hidden {
  display: none;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

@media (hover: none), (pointer: coarse) {
  .cursor-tag {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor-tag-caret {
    animation: none;
  }
}

/* ---------- About frames ---------- */

.frame-about-info,
.frame-about-experience {
  width: 440px;
}

.frame-socials {
  width: 440px;
}

.frame-credits {
  width: 240px;
}

.about-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: calc(48px * var(--text-scale));
  margin-bottom: calc(24px * var(--text-scale));
  color: var(--text-primary);
}

.about-text {
  position: relative;
  font-family: var(--font-body);
  font-size: calc(17px * var(--text-scale));
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: calc(20px * var(--text-scale));
}

.about-meta {
  font-family: var(--font-body);
  font-size: calc(14px * var(--text-scale));
  color: var(--text-faint);
  margin-bottom: calc(32px * var(--text-scale));
}

/* ---------- Credits: Figma sticky-note look ---------- */

.sticky-note {
  width: 240px;
  height: 240px;
  background: #f5dc9a;
  padding: calc(18px * var(--text-scale));
  border-radius: 4px;
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.175), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sticky-text {
  font-family: var(--font-body);
  font-size: calc(14px * var(--text-scale));
  line-height: 1.45;
  color: #2b2416;
  margin-bottom: calc(14px * var(--text-scale));
}

.sticky-meta {
  font-family: var(--font-body);
  font-size: calc(12px * var(--text-scale));
  color: rgba(43, 36, 22, 0.6);
}

.social-icons {
  display: flex;
  align-items: center;
  gap: calc(20px * var(--text-scale));
}

.social-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 4px of extra clickable area on every side — the negative margin cancels
     it back out so the icon's own visual size and spacing don't change. */
  width: calc(24px * var(--text-scale) + 8px);
  height: calc(24px * var(--text-scale) + 8px);
  padding: 4px;
  margin: -4px;
}

.social-link img {
  width: 100%;
  height: 100%;
  filter: invert(var(--icon-invert));
}

.experience-list {
  display: flex;
  flex-direction: column;
  gap: calc(36px * var(--text-scale));
}

.job-entry {
  position: relative;
  display: block;
  border-radius: 8px;
  margin: -8px;
  padding: 8px;
}

.job-header {
  display: flex;
  align-items: center;
  gap: calc(0.55rem * var(--text-scale));
  margin-bottom: calc(0.4rem * var(--text-scale));
}

.job-header h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: calc(19px * var(--text-scale));
  color: var(--text-primary);
}

.job-link {
  color: inherit;
  text-decoration: none;
}

.job-link:hover {
  text-decoration: underline;
}

.job-icon {
  flex-shrink: 0;
  width: calc(18px * var(--text-scale));
  height: calc(18px * var(--text-scale));
  border-radius: 4px;
  object-fit: cover;
}

.job-desc {
  font-family: var(--font-body);
  font-size: calc(16px * var(--text-scale));
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: calc(0.5rem * var(--text-scale));
}

.job-date {
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-faint);
}

@media (prefers-reduced-motion: reduce) {
  .section-bg-img {
    transition: none;
  }
}

/* Mobile and tablet use the exact same layout, styling and behavior as
   desktop (see layoutFrames() in script.js — it isn't viewport-specific) —
   the only difference is a smaller default zoom (defaultScaleForViewport())
   so the whole canvas fits on a smaller screen at a glance. */
@media (max-width: 639px) {
  /* The collaborator cursor normally only shows on hover, which doesn't
     really exist on touch — show it unconditionally here instead (see the
     isMobileLayout() branch in script.js that activates it on load). */
  .cursor-tag {
    display: block;
  }
}
