@import url("https://api.fontshare.com/v2/css?f[]=clash-grotesk@700&f[]=general-sans@400,500,600,700&display=swap");

:root {
  --bg: #e3e2de;
  --ink: #1b0e0d;
  --accent: #c72a09;
  --accent-deep: #61220f;
  --neon: #31ef07;
  --muted: #6e625d;
  --line: rgba(27, 14, 13, 0.16);
  --display: "Clash Grotesk", "Arial Black", sans-serif;
  --body: "General Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --ease-out: cubic-bezier(0.165, 0.84, 0.44, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top, rgba(199, 42, 9, 0.08), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: var(--body);
}

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

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(100% - 2rem, 1480px);
  margin: 0 auto;
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

.builder-header {
  position: sticky;
  top: 0;
  z-index: 40;
  mix-blend-mode: difference;
}

.builder-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 86px;
  color: var(--bg);
  text-transform: uppercase;
  font-weight: 700;
}

.builder-nav__links {
  display: flex;
  gap: 1.4rem;
  justify-content: center;
}

.builder-nav__links:last-child {
  justify-content: flex-end;
}

.brand,
.builder-nav a {
  position: relative;
  width: fit-content;
  letter-spacing: 0.08em;
}

.brand {
  font-size: clamp(1.1rem, 1rem + 0.7vw, 1.5rem);
}

.brand__mount {
  display: inline-flex;
  align-items: center;
  min-height: 1.6rem;
}

.brand::after,
.builder-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.3rem;
  width: 100%;
  height: 2px;
  background: var(--neon);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 300ms var(--ease-out);
}

.brand:hover::after,
.builder-nav a:hover::after,
.brand:focus-visible::after,
.builder-nav a:focus-visible::after {
  transform: scaleX(1);
}

.builder-main {
  padding: 2rem 0 4rem;
}

.builder-auth-status {
  padding: 1rem 0 0;
}

.builder-auth-status p {
  margin: 0;
  padding: 0.95rem 1rem;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.5);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.builder-hero {
  display: grid;
  gap: 0.9rem;
  max-width: 70rem;
  margin-bottom: 2rem;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.builder-hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.2rem, 7vw, 7.8rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 0.9;
  text-transform: uppercase;
}

.builder-hero p:last-child {
  margin: 0;
  max-width: 44rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  line-height: 1.8;
  text-transform: uppercase;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.95fr) minmax(460px, 1.05fr);
  gap: 1.5rem;
  align-items: start;
}

.form-panel,
.canvas-panel {
  border: 1px solid var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    rgba(199, 42, 9, 0.04);
}

.form-panel {
  padding: 1.25rem;
}

.resume-form {
  display: grid;
  gap: 1rem;
}

.form-section {
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
}

.form-section legend {
  padding: 0 0.45rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.form-note {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.input-grid--single {
  grid-template-columns: 1fr;
}

.input-grid label {
  display: grid;
  gap: 0.45rem;
}

.input-grid span,
.repeater-item__top p,
.canvas-meta {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.input-grid input,
.input-grid textarea {
  width: 100%;
  padding: 0.82rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.34);
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.input-grid input:focus,
.input-grid textarea:focus {
  border-color: var(--neon);
  box-shadow: inset 0 0 0 1px var(--neon);
  background: rgba(255, 255, 255, 0.6);
}

.input-grid textarea {
  resize: vertical;
  min-height: 110px;
}

.input-grid__full {
  grid-column: 1 / -1;
}

.repeater-list {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 0.85rem;
}

.repeater-item {
  padding: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
}

.repeater-item__top,
.canvas-meta,
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.action-button,
.remove-button,
.primary-button,
.secondary-button,
.auth-slot--dark {
  min-height: 46px;
}

.auth-user {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  max-width: min(42vw, 420px);
}

.auth-user__email,
.auth-user__button {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-user__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-user__button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bg);
  cursor: pointer;
}

.action-button,
.remove-button,
.primary-button,
.secondary-button {
  padding: 0 1rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.action-button:hover,
.remove-button:hover,
.secondary-button:hover,
.action-button:focus-visible,
.remove-button:focus-visible,
.secondary-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible {
  border-color: var(--neon);
  background: rgba(49, 239, 7, 0.12);
  color: var(--ink);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--neon);
}

.form-status {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.form-status[data-state="success"] {
  color: var(--accent-deep);
}

.form-status[data-state="error"] {
  color: #a21f00;
}

.primary-button[disabled] {
  opacity: 0.6;
  cursor: wait;
}

.canvas-panel {
  position: sticky;
  top: 96px;
  padding: 1rem;
}

.canvas-meta {
  margin-bottom: 0.9rem;
}

.canvas-stage {
  display: grid;
  justify-items: center;
  overflow: auto;
  padding: 0.3rem 0 0.1rem;
}

#resume-canvas {
  width: min(100%, 720px);
  height: auto;
  background: #ffffff;
  box-shadow: 0 32px 70px rgba(17, 17, 17, 0.16);
}

/* ── Builder Keyframe Animations ── */

@keyframes builderFadeUp {
  from { opacity: 0; transform: translateY(36px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes builderSlideRight {
  from { opacity: 0; transform: translateX(-40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes builderSlideLeft {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes builderScaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes canvasShimmer {
  from { box-shadow: 0 32px 70px rgba(17, 17, 17, 0.16); }
  50%  { box-shadow: 0 32px 90px rgba(17, 17, 17, 0.24), 0 0 0 1px rgba(49, 239, 7, 0.08); }
  to   { box-shadow: 0 32px 70px rgba(17, 17, 17, 0.16); }
}

@keyframes pulseGlow {
  0%, 100% { border-color: var(--line); }
  50%      { border-color: rgba(49, 239, 7, 0.3); }
}

@keyframes statusSlide {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Entrance ── */

.builder-header {
  animation: builderFadeUp 600ms var(--ease-out) 100ms both;
}

.builder-auth-status {
  animation: statusSlide 500ms var(--ease-out) 200ms both;
}

.builder-hero .eyebrow {
  animation: builderFadeUp 700ms var(--ease-out) 300ms both;
}

.builder-hero h1 {
  animation: builderFadeUp 800ms var(--ease-out) 450ms both;
}

.builder-hero p:last-child {
  animation: builderFadeUp 700ms var(--ease-out) 600ms both;
}

.form-panel {
  animation: builderSlideRight 800ms var(--ease-out) 700ms both;
}

.canvas-panel {
  animation: builderSlideLeft 800ms var(--ease-out) 850ms both;
}

/* ── Canvas Glow ── */

#resume-canvas {
  animation: canvasShimmer 5s ease-in-out 2s infinite;
}

/* ── Repeater Item Entrance ── */

.repeater-item {
  animation: builderScaleIn 400ms var(--ease-out) both;
}

/* ── Input Focus Pulse ── */

.input-grid input:focus,
.input-grid textarea:focus {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ── Button Hover Enhancements ── */

.action-button,
.remove-button,
.primary-button,
.secondary-button {
  position: relative;
  overflow: hidden;
}

.action-button::after,
.primary-button::after,
.secondary-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(49, 239, 7, 0.15);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 500ms ease, height 500ms ease;
  pointer-events: none;
}

.action-button:hover::after,
.primary-button:hover::after,
.secondary-button:hover::after {
  width: 260px;
  height: 260px;
}

/* ── Form Section Stagger ── */

.form-section:nth-child(1) { animation: builderFadeUp 600ms var(--ease-out) 800ms both; }
.form-section:nth-child(2) { animation: builderFadeUp 600ms var(--ease-out) 950ms both; }
.form-section:nth-child(3) { animation: builderFadeUp 600ms var(--ease-out) 1100ms both; }

/* ── Auth State Transitions ── */

body.auth-pending .builder-main {
  opacity: 0.25;
  pointer-events: none;
  filter: blur(2px);
  transition: opacity 600ms ease, filter 600ms ease;
}

body.is-authenticated .builder-main {
  opacity: 1;
  pointer-events: auto;
  filter: blur(0);
  transition: opacity 600ms ease, filter 600ms ease;
}

@media (max-width: 1100px) {
  .builder-nav {
    grid-template-columns: 1fr;
    justify-items: start;
    padding: 1rem 0;
  }

  .builder-nav__links,
  .builder-nav__links:last-child {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .canvas-panel {
    position: relative;
    top: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 1.25rem, 1480px);
  }

  .input-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .noise,
  .builder-header,
  .builder-hero,
  .form-panel {
    display: none !important;
  }

  .builder-main,
  .workspace,
  .canvas-panel,
  .canvas-stage {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #resume-canvas {
    width: 8.5in;
    box-shadow: none;
  }
}
