/* ============================================================
   MATVEY KHVAL — PORTFOLIO
   Design system: technical drafting / blueprint sheet
   ============================================================ */

:root {
  --paper: #eaeff3;
  --paper-2: #dfe6ec;
  --ink: #152238;
  --ink-soft: #2c3c56;
  --graphite: #5a6b7d;
  --line: #b9c6d4;
  --line-strong: #8fa2b5;
  --flame: #e15a24;
  --flame-dim: #c94f1e;
  --ok: #2e7d5b;

  --font-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;

  --sheet-margin: clamp(16px, 4vw, 40px);
  --content-max: 920px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--flame);
  color: var(--paper);
}

a {
  color: var(--ink);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--flame); }

:focus-visible {
  outline: 2px solid var(--flame);
  outline-offset: 3px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em 0; max-width: 66ch; }

.sheet {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--sheet-margin);
}

/* ---------- corner registration marks ---------- */
.register {
  position: relative;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.35);
}
.register::before,
.register::after,
.register .corner-tl,
.register .corner-br {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.register::before {
  top: -1px; left: -1px;
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
}
.register::after {
  bottom: -1px; right: -1px;
  border-bottom: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(234, 239, 243, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-strong);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px var(--sheet-margin);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-id {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--graphite);
  white-space: nowrap;
}
.nav-id strong { color: var(--ink); font-weight: 600; }
.nav-links {
  display: flex;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 13.5px;
}
.nav-links a { text-decoration: none; color: var(--ink-soft); }
.nav-links a:hover { color: var(--flame); }

/* ---------- hero ---------- */
.hero {
  padding: clamp(56px, 10vw, 108px) 0 clamp(40px, 7vw, 70px);
  position: relative;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(24px, 4vw, 56px);
  align-items: center;
}
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
}
.hero-kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--flame-dim);
  margin: 0 0 14px 0;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.04;
  color: var(--ink);
}
.hero-role {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--graphite);
  margin-top: 18px;
}
.hero-desc {
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 1.05rem;
}
.hero-actions {
  margin-top: 30px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 11px 20px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--flame);
  border-color: var(--flame);
  color: var(--paper);
}
.btn-primary:hover { background: var(--flame-dim); border-color: var(--flame-dim); color: var(--paper); }

/* trajectory diagram */
.trajectory-wrap {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.4);
  padding: 18px;
  position: relative;
}
.trajectory-wrap .label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--graphite);
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
#trajectory-path {
  fill: none;
  stroke: var(--flame);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 620;
  stroke-dashoffset: 620;
  animation: draw-path 2.2s ease-out 0.3s forwards;
}
#trajectory-plane {
  offset-path: path("M 10 200 C 60 40, 140 20, 200 60 S 320 190, 400 40");
  offset-rotate: auto;
  animation: move-plane 2.4s ease-out 0.3s forwards;
  opacity: 0;
}
#trajectory-plane path {
  fill: var(--flame);
  stroke: var(--ink);
  stroke-width: 0.75;
  stroke-linejoin: round;
}
@keyframes draw-path {
  to { stroke-dashoffset: 0; }
}
@keyframes move-plane {
  0% { offset-distance: 0%; opacity: 0; }
  4% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #trajectory-path { stroke-dashoffset: 0; animation: none; }
  #trajectory-plane { animation: none; offset-distance: 100%; opacity: 1; }
}

/* ---------- flyby divider ---------- */
.flyby {
  position: relative;
  height: 1px;
  border-top: 1px dashed var(--line-strong);
  margin: 0 var(--sheet-margin);
  overflow: visible;
}
.flyby-alt { margin: 0 var(--sheet-margin) -1px; }
.flyby-plane {
  position: absolute;
  top: -26px;
  left: -66px;
  opacity: 0;
}
.flyby-plane path {
  fill: none;
  stroke: var(--flame-dim);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.flyby.in-view .flyby-plane {
  animation: flyby-move 3.2s ease-in-out forwards;
}
@keyframes flyby-move {
  0% { left: -66px; opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { left: calc(100% + 20px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .flyby-plane { left: 50%; opacity: 1; animation: none !important; }
}

/* ---------- rocket icon (project card) ---------- */
.project-card--rocket { position: relative; }
.rocket-icon {
  position: absolute;
  top: 22px;
  right: 22px;
}
.rocket-icon .rocket-body { fill: var(--ink); }
.rocket-icon .rocket-fin-l,
.rocket-icon .rocket-fin-r { fill: var(--ink-soft); }
.rocket-icon .rocket-window { fill: var(--paper); }
.rocket-icon .rocket-flame {
  fill: var(--flame);
  transform-box: fill-box;
  transform-origin: 50% 0%;
}
.project-card--rocket:hover .rocket-flame {
  animation: flicker 0.45s ease-in-out infinite alternate;
}
@keyframes flicker {
  from { transform: scaleY(0.85); opacity: 0.75; }
  to { transform: scaleY(1.2); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .project-card--rocket:hover .rocket-flame { animation: none; }
}

/* ---------- sections ---------- */
section { padding: clamp(64px, 11vw, 116px) 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 44px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong);
}
.section-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--flame-dim);
}
.section-head h2 {
  font-size: clamp(1.6rem, 3.4vw, 2.1rem);
}

/* ---------- projects ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1px;
  background: var(--line-strong);
  border: 1px solid var(--line-strong);
}
.project-card {
  background: var(--paper);
  padding: 34px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.project-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--flame-dim);
}
.project-card h3 {
  font-size: 1.3rem;
}
.project-desc {
  color: var(--ink-soft);
  font-size: 0.97rem;
  flex-grow: 1;
}
.spec-table {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--graphite);
  border-top: 1px dashed var(--line-strong);
  padding-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
}
.spec-table dt { color: var(--graphite); }
.spec-table dd { margin: 0; color: var(--ink-soft); }
.project-link {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- skills / preflight checklist ---------- */
.checklist-panel {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.4);
}
.checklist-panel-head {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--graphite);
  padding: 16px 24px;
  border-bottom: 1px solid var(--line-strong);
  display: flex;
  justify-content: space-between;
}
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.checklist li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 17px 24px;
  border-bottom: 1px dashed var(--line);
  font-size: 0.98rem;
}
.checklist li:last-child { border-bottom: none; }
.check-box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--ink);
  position: relative;
  flex-shrink: 0;
}
.check-box::after {
  content: "";
  position: absolute;
  left: 3px; top: -1px;
  width: 5px; height: 10px;
  border-right: 2px solid var(--flame);
  border-bottom: 2px solid var(--flame);
  transform: rotate(42deg);
}
.check-status {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ok);
  white-space: nowrap;
}
.checklist-group-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--flame-dim);
  padding: 14px 20px 4px;
}

/* ---------- contact ---------- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
@media (max-width: 760px) {
  .contact-grid { grid-template-columns: 1fr; }
}
.panel {
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.4);
  padding: 32px 28px;
}
.panel-title {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--graphite);
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--graphite);
  margin-bottom: 6px;
}
.field input,
.field textarea {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink);
}
.field input:focus,
.field textarea:focus {
  border-color: var(--flame);
  outline: none;
}
.field textarea { resize: vertical; min-height: 110px; }
.form-status {
  font-family: var(--font-mono);
  font-size: 13px;
  margin-top: 12px;
  min-height: 1.2em;
}
.form-status.ok { color: var(--ok); }
.form-status.err { color: var(--flame); }

#calendly-embed {
  min-width: 280px;
  height: 560px;
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--line-strong);
  padding: 26px var(--sheet-margin) 40px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--graphite);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}



/* ---------- 404 page ---------- */
.error-page {
  min-height: calc(100vh - 132px);
  display: flex;
  align-items: center;
  padding: 56px 0;
}
.error-panel {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px);
  text-align: center;
}
.error-panel h1 {
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 1.02;
  margin-bottom: 18px;
}
.error-panel p:not(.hero-kicker):not(.error-code) {
  max-width: 48ch;
  margin: 0 auto 28px;
  color: var(--ink-soft);
}
.error-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--flame-dim);
  margin-bottom: 24px;
}
.error-panel .btn { margin-top: 4px; }

@media (max-width: 560px) {
  .error-page { min-height: calc(100vh - 116px); }
  .error-panel { padding: 36px 22px; }
  .error-panel h1 { font-size: clamp(2.25rem, 12vw, 3.5rem); }
  .error-body .nav-id { font-size: 11px; }
  .error-body .nav-inner { gap: 10px; }
  .error-body .nav .btn { padding: 9px 12px; font-size: 12px; }
}