/* ========================================
   Resume — A4 document view
   ----------------------------------------
   Loaded AFTER portfolio.css and deliberately
   NOT wrapped in @layer: portfolio.css ships
   unlayered, and unlayered rules outrank
   layered ones, so a layer here would lose
   every shared selector (.navbar, .footer).
   ======================================== */

/* Animatable custom properties (progressive — ignored where unsupported) */
@property --sheen {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

:root {
  /* Paper geometry — real ISO 216 A4 */
  --paper-w: 210mm;
  --paper-h: 297mm;
  --paper-pad: 14mm;

  /* Set by resume.js; the fallback keeps the page usable without JS */
  --paper-scale: 1;

  /* Document-local palette: a resume should read as paper, and print as paper */
  --ink: hsl(220, 25%, 12%);
  --ink-soft: hsl(220, 12%, 38%);
  --ink-faint: hsl(220, 12%, 55%);
  --rule: hsl(220, 15%, 86%);
  --paper-bg: hsl(0, 0%, 100%);
  --paper-accent: hsl(160, 85%, 26%);
}

/* ---------- Page shell ---------- */
.resume-page {
  min-height: 100vh;
  min-height: 100dvh;
}

.resume-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 7rem 1.5rem 4rem;
}

.resume-head {
  text-align: center;
  margin-bottom: 2rem;
}

.resume-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.resume-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.75rem;
}

/* ---------- Toolbar ---------- */
.resume-toolbar {
  position: sticky;
  top: 4.5rem;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.75rem;
}

.tool-group {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.35rem;
  background: hsla(220, 20%, 10%, 0.75);
  border: 1px solid var(--border);
  border-radius: 50px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 2.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 50px;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.25s,
    border-color 0.25s,
    color 0.25s,
    transform 0.25s;
}

.tool-btn:hover {
  background: hsla(160, 100%, 50%, 0.1);
  border-color: hsla(160, 100%, 50%, 0.4);
  color: var(--accent);
}

.tool-btn:active {
  transform: scale(0.95);
}

/* Visible keyboard focus — the theme had none */
.tool-btn:focus-visible,
.nav-link:focus-visible,
.nav-btn:focus-visible,
.footer-links a:focus-visible,
.doc-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.tool-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.tool-btn[disabled]:hover {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
}



.tool-accent {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.tool-accent:hover {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: var(--glow);
}

/* ----------------------------------------
   View switcher
   ---------------------------------------- */
.view-tabs {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
}

.view-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 50px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.25s,
    color 0.25s,
    border-color 0.25s;
}

.view-tab:hover {
  color: var(--accent);
}

.view-tab.is-active {
  background: hsla(160, 100%, 50%, 0.12);
  border-color: hsla(160, 100%, 50%, 0.45);
  color: var(--accent);
}

.view-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.view[hidden] {
  display: none;
}

/* ----------------------------------------
   Live Google Docs embed

   Google's viewer is responsive: narrow it
   and it reflows, hyphenating the title and
   breaking bullets mid-word. So the iframe
   is pinned to a natural width where the
   document lays out cleanly and is scaled
   down to fit, exactly like the paper stage.
   ---------------------------------------- */
.gdoc-viewport {
  width: 100%;
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}

.gdoc-viewport::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.gdoc-sizer {
  position: relative;
  /* width/height written by resume.js */
  margin-inline: auto;
  border-radius: 8px;
  overflow: hidden;
}

/* ----------------------------------------
   Techie Loading Animation
   ---------------------------------------- */
.tech-loader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  background: hsla(220, 30%, 6%, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 4px;
  border: 1px solid hsla(160, 100%, 50%, 0.25);
  box-shadow: 0 0 35px hsla(160, 100%, 50%, 0.1);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.tech-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tech-spinner {
  position: relative;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  border-radius: 50%;
  animation: techSpin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  box-shadow: 0 0 15px hsla(160, 100%, 50%, 0.4);
}

.spinner-ring.inner {
  inset: 10px;
  border-top-color: transparent;
  border-right-color: transparent;
  border-bottom-color: var(--accent-secondary, #00d2ff);
  border-left-color: var(--accent-secondary, #00d2ff);
  animation: techSpinReverse 0.9s linear infinite;
  box-shadow: none;
}

.spinner-core {
  font-size: 1.15rem;
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

.tech-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tech-text {
  color: var(--accent);
  text-shadow: 0 0 10px hsla(160, 100%, 50%, 0.5);
}

.tech-dots {
  color: var(--text-secondary);
  animation: pulse 1s infinite;
}

.tech-bar {
  width: 180px;
  height: 3px;
  background: hsla(220, 20%, 15%, 0.8);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid hsla(160, 100%, 50%, 0.2);
}

.tech-progress {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-secondary, #00d2ff));
  box-shadow: 0 0 10px var(--accent);
  border-radius: 4px;
  animation: techScan 1.6s ease-in-out infinite alternate;
}

@keyframes techSpin {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes techSpinReverse {
  100% {
    transform: rotate(-360deg);
  }
}

@keyframes techScan {
  0% {
    transform: translateX(-10%);
    width: 25%;
  }
  50% {
    width: 60%;
  }
  100% {
    transform: translateX(260%);
    width: 30%;
  }
}

.gdoc-frame {
  width: var(--gdoc-w);
  height: var(--gdoc-h);
  border: 0;
  display: block;
  background: var(--bg-primary, #0b0f17);
  border-radius: 2px;
  box-shadow:
    0 0 0 1px hsla(160, 100%, 50%, 0.18),
    0 24px 70px hsla(220, 40%, 2%, 0.75);
  transform: scale(var(--gdoc-scale, 1));
  transform-origin: top left;
}

.gdoc-fallback {
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.gdoc-fallback[hidden] {
  display: none;
}

/* ----------------------------------------
   Paper stage

   Three boxes, because `transform` is not a
   layout operation — a scaled sheet keeps
   its unscaled 210mm footprint. The sizer
   carries the *scaled* dimensions so the
   page reserves the right space, and the
   viewport owns the scrollbar so zooming
   past fit stays reachable instead of being
   clipped by body{overflow-x:hidden}.
   ---------------------------------------- */
.paper-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.paper-viewport::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.paper-sizer {
  /* width/height written by resume.js */
  margin-inline: auto;
  transition: height 0.2s ease;
}

/* The transformed stack of sheets */
.pages {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  width: max-content;
  transform: scale(var(--paper-scale, 1));
  transform-origin: top left;
}

.paper {
  position: relative;
  box-sizing: border-box;
  width: var(--paper-w);
  height: var(--paper-h);
  flex-shrink: 0;
  padding: var(--paper-pad);
  background: var(--paper-bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 10.2pt;
  line-height: 1.5;
  text-align: left;
  border-radius: 2px;
  box-shadow:
    0 0 0 1px hsla(160, 100%, 50%, 0.18),
    0 24px 70px hsla(220, 40%, 2%, 0.75);
  contain: layout style;
}

/* Content box the paginator measures against */
.paper-inner {
  height: 100%;
  overflow: hidden;
}

.paper-foot {
  position: absolute;
  inset: auto var(--paper-pad) calc(var(--paper-pad) - 8mm) var(--paper-pad);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 7.2pt;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
  padding-top: 2mm;
}

/* Accent spine down the left edge of each sheet */
.paper::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-secondary));
  border-radius: 2px 0 0 2px;
}

/* Continuous mode: one sheet that grows with the content */
.pages--flow .paper {
  height: auto;
  min-height: 0;
}

.pages--flow .paper-inner {
  height: auto;
  overflow: visible;
}

.pages--flow .paper-foot {
  display: none;
}

/* ---------- Document header ---------- */
.doc-head {
  padding-bottom: 0.7rem;
  margin-bottom: 1.1rem;
  border-bottom: 2px solid var(--ink);
}

.doc-name {
  font-family: var(--font-mono);
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.doc-role {
  margin-top: 0.15rem;
  font-size: 10.5pt;
  font-weight: 600;
  color: var(--paper-accent);
}

.doc-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.9rem;
  margin-top: 0.55rem;
  list-style: none;
  font-size: 8.8pt;
  color: var(--ink-soft);
}

.doc-contact li {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.doc-contact i {
  color: var(--paper-accent);
  font-size: 0.9em;
}

.doc-link {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition:
    color 0.2s,
    border-color 0.2s;
}

.doc-link:hover {
  color: var(--paper-accent);
  border-color: var(--paper-accent);
}

/* ---------- Document sections ---------- */
.doc-section {
  margin-bottom: 1.05rem;
  /* Never orphan a heading at the bottom of a printed page */
  break-inside: auto;
}

.doc-section--last {
  margin-bottom: 0;
}

.doc-h {
  font-family: var(--font-mono);
  font-size: 9.6pt;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--paper-accent);
  padding-bottom: 0.2rem;
  margin-top: 0.95rem;
  margin-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule);
  break-after: avoid;
}

/* Items are flowed flat onto sheets, so the first one sets its own top edge */
.paper-inner > *:first-child {
  margin-top: 0;
}

/* Entry (job / project / school) */
.doc-entry {
  margin-bottom: 0.85rem;
  break-inside: avoid;
}

.doc-entry:last-child {
  margin-bottom: 0;
}

.doc-entry-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.doc-entry-role {
  font-size: 11pt;
  font-weight: 700;
  color: var(--ink);
}

.doc-entry-date {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 8.4pt;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}

.doc-entry-org {
  font-size: 9.4pt;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

/* "Present" role gets a live dot */
.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid color-mix(in srgb, var(--paper-accent) 35%, transparent);
  border-radius: 50px;
  background: color-mix(in srgb, var(--paper-accent) 8%, transparent);
  font-family: var(--font-mono);
  font-size: 7pt;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper-accent);
  vertical-align: middle;
}

.doc-chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--paper-accent);
  animation: pulse 2s infinite;
}

/* Bullet lists */
.doc-list {
  list-style: none;
  padding-left: 0;
}

.doc-list li {
  position: relative;
  padding-left: 0.95rem;
  margin-bottom: 0.22rem;
  font-size: 9.4pt;
  color: var(--ink);
  break-inside: avoid;
}

.doc-list li::before {
  content: '';
  position: absolute;
  left: 0.15rem;
  top: 0.52em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--paper-accent);
}

/* Stack / coursework chips */
.doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-bottom: 0.35rem;
}

.doc-tag {
  padding: 0.08rem 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: hsl(220, 20%, 97%);
  font-family: var(--font-mono);
  font-size: 7.6pt;
  color: var(--ink-soft);
}

/* Skills grid */
.doc-skills {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.34rem 0.85rem;
  align-items: baseline;
}

.doc-skill-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 8.6pt;
  font-weight: 700;
  color: var(--paper-accent);
  white-space: nowrap;
}

.doc-skill-items {
  font-size: 9.2pt;
  color: var(--ink);
}

/* Achievements get a year gutter */
.doc-list--achieve li {
  padding-left: 0;
  display: grid;
  grid-template-columns: 3.6rem 1fr;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.doc-list--achieve li::before {
  display: none;
}

.doc-year {
  font-family: var(--font-mono);
  font-size: 8pt;
  font-weight: 700;
  color: var(--paper-accent);
  text-align: right;
}

.doc-coursework {
  margin-top: 0.3rem;
  font-size: 8.8pt;
  color: var(--ink-soft);
}

.doc-coursework strong {
  color: var(--ink);
  font-weight: 600;
}

.resume-note {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.resume-note a {
  color: var(--accent);
  text-decoration: none;
}

.resume-note a:hover {
  text-decoration: underline;
}

/* ========================================
   Responsive — below the A4 breakpoint the
   sheet stops being a sheet and becomes a
   fluid, readable document. Scaling 210mm
   down to a 360px screen would render body
   text at roughly 4pt.
   ======================================== */
@media (max-width: 820px) {
  .resume-main {
    padding: 5.5rem 0.75rem 2.5rem;
  }

  .resume-toolbar {
    top: 3.8rem;
    gap: 0.5rem;
  }



  .view-tabs {
    flex: 1;
    max-width: 15rem;
  }

  .view-tab {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }

  .tool-btn {
    padding: 0.5rem 0.7rem;
    font-size: 0.78rem;
  }

  /* Media query alone keeps flow mode correct even before JS runs */
  .paper-viewport {
    overflow-x: visible;
  }

  .paper-sizer {
    width: auto !important;
    height: auto !important;
  }

  .pages {
    width: 100%;
    transform: none !important;
  }

  .paper {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 1.5rem 1.15rem 1.75rem;
    font-size: 13.5px;
    border-radius: 8px;
    box-shadow:
      0 0 0 1px hsla(160, 100%, 50%, 0.2),
      0 12px 40px hsla(220, 40%, 2%, 0.6);
  }

  .paper-inner {
    height: auto;
    overflow: visible;
  }

  .paper-foot {
    display: none;
  }

  .doc-name {
    font-size: 1.5rem;
  }

  .doc-role {
    font-size: 0.95rem;
  }

  .doc-contact {
    font-size: 0.82rem;
    gap: 0.4rem 0.85rem;
  }

  .doc-h {
    font-size: 0.8rem;
    margin-top: 0.9rem;
    margin-bottom: 0.5rem;
  }

  .doc-entry-role {
    font-size: 0.98rem;
  }

  .doc-entry-top {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.2rem 0.75rem;
  }

  .doc-entry-org,
  .doc-list li {
    font-size: 0.88rem;
  }

  .doc-entry-date {
    font-size: 0.78rem;
  }

  .doc-skills {
    grid-template-columns: auto 1fr;
    gap: 0.35rem 0.75rem;
    align-items: baseline;
  }

  .doc-skill-label {
    font-size: 0.8rem;
    margin-top: 0;
  }

  .doc-skill-items {
    font-size: 0.88rem;
  }

  .doc-list--achieve li {
    grid-template-columns: 3.2rem 1fr;
    gap: 0.5rem;
  }

  .doc-year {
    font-size: 0.78rem;
    text-align: right;
  }
}

@media (max-width: 480px) {
  .resume-main {
    padding: 5rem 0.5rem 2rem;
  }

  .resume-toolbar {
    gap: 0.5rem;
  }

  .tool-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  .paper {
    padding: 1.25rem 0.9rem 1.5rem;
  }

  .doc-contact {
    font-size: 0.78rem;
    gap: 0.35rem 0.65rem;
  }

  .doc-list--achieve li {
    grid-template-columns: 2.8rem 1fr;
    gap: 0.4rem;
  }
}

/* Respect motion preferences */
@media (prefers-reduced-motion: reduce) {
  .paper-sizer,
  .tool-btn,
  .doc-link {
    transition: none;
  }

  .doc-chip::before {
    animation: none;
  }
}

/* ========================================
   Print — emit a clean A4 document only
   ======================================== */
@page {
  size: A4;
  margin: 11mm 12mm;
}

@media print {
  .navbar,
  .resume-toolbar,
  .resume-head,
  .resume-note,
  .view-tabs,
  .footer,
  .orb,
  .bg-grid,
  .tech-loader {
    display: none !important;
  }

  /* Always print the rendered sheets, whichever tab is on screen: a
     cross-origin iframe prints as a clipped single frame at best. */
  #viewLive {
    display: none !important;
  }

  #viewRendered {
    display: block !important;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .resume-main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .paper-viewport {
    overflow: visible;
  }

  .paper-sizer {
    width: auto !important;
    height: auto !important;
    margin: 0;
  }

  /* Let the print engine do the pagination; the on-screen sheets would
     otherwise nest a fixed 297mm box inside an already-paginated page. */
  .pages {
    display: block;
    width: auto;
    gap: 0;
    transform: none !important;
  }

  .paper {
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 0;
    font-size: 10pt;
    box-shadow: none;
    border-radius: 0;
    contain: none;
    break-after: page;
  }

  .paper:last-child {
    break-after: auto;
  }

  .paper-inner {
    height: auto;
    overflow: visible;
  }

  .paper-foot {
    display: none;
  }

  /* The neon spine wastes toner and clips at the margin */
  .paper::before {
    display: none;
  }

  .doc-link {
    border-bottom: none;
  }

  .doc-entry,
  .doc-list li {
    break-inside: avoid;
  }

  .doc-h {
    break-after: avoid;
  }
}
