/* =============================================================
   Cynthia Patel — Software Engineer Portfolio
   Signature features: sunflower photo card, sealed envelope
   contact letter and the quill "writing" engine styles
   ============================================================= */
:root {
  --gold: #f2c14e;
  --gold-deep: #d9a437;
  --seed: #6b4423;
  --paper: #fffdf9;
  --paper-line: rgba(35, 40, 45, 0.08);
  --ink-wet: #2f4858;
  --hand: "Caveat", "Segoe Script", "Bradley Hand", cursive;
}

/* ---- generic "written" text: characters are revealed left→right ---- */
.hw .w { display: inline-block; white-space: pre; }
.hw .c { display: inline-block; clip-path: inset(-6px 100% -6px 0); opacity: 0; }
.hw .c.on {
  clip-path: inset(-6px 0 -6px 0);
  opacity: 1;
  transition: clip-path var(--cd, 40ms) linear, opacity 20ms linear;
}
.hw.done .c { clip-path: none; }

/* ---- the quill ---- */
.quill {
  position: absolute;
  left: 0; top: 0;
  width: 54px;
  height: 136px;
  pointer-events: none;
  opacity: 0;
  transform: translate(110%, -30%);
  transition: transform 70ms linear, opacity 0.45s ease;
  z-index: 6;
  filter: drop-shadow(0 10px 10px rgba(35, 40, 45, 0.28));
  will-change: transform;
}
.quill.show { opacity: 1; }
.quill.lift { transition: transform 240ms var(--ease), opacity 0.45s ease; }
.quill.away { transition: transform 0.9s var(--ease), opacity 0.6s ease; opacity: 0; }
.quill.circling svg { animation: orbit 1.1s linear infinite; }
@keyframes orbit {
  0% { transform: translate(0, 0); }
  25% { transform: translate(9px, -6px); }
  50% { transform: translate(0, -12px); }
  75% { transform: translate(-9px, -6px); }
  100% { transform: translate(0, 0); }
}
.quill svg { width: 100%; height: 100%; overflow: visible; }
.quill .vane { fill: var(--teal-soft); stroke: var(--teal); stroke-width: 1.6; }
.quill .barb { fill: none; stroke: var(--teal); stroke-width: 1; opacity: 0.55; }
.quill .shaft { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.quill .nib { fill: var(--ink); }
.quill .spark { fill: var(--gold); opacity: 0; transform-origin: center; }
.quill.writing .spark { animation: spark 0.9s ease-in-out infinite; }
.quill.writing .spark:nth-child(2) { animation-delay: 0.3s; }
.quill.writing .spark:nth-child(3) { animation-delay: 0.6s; }
@keyframes spark { 0%, 100% { opacity: 0; transform: translate(0, 0) scale(0.4); } 50% { opacity: 0.9; transform: translate(-4px, -8px) scale(1); } }
.quill--small { width: 40px; height: 100px; }

/* ---- drawn SVG strokes (doodle, signature swoosh) ---- */
.draw { stroke-dasharray: var(--len, 400) var(--len, 400); stroke-dashoffset: var(--len, 400); }
.draw.go { animation: drawPath var(--t, 1s) var(--ease) forwards; }
@keyframes drawPath { to { stroke-dashoffset: 0; } }
.doodle-box { flex: none; line-height: 0; }
.doodle { width: 78px; height: 78px; }
.doodle path, .doodle circle { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.doodle .petals { stroke: var(--gold-deep); stroke-width: 2.2; }
.doodle .disc { stroke: var(--seed); stroke-width: 2.4; }
.doodle .seeds { stroke: var(--seed); stroke-width: 2; stroke-dasharray: 1 5; opacity: 0; transition: opacity 0.6s; }
.doodle.seeded .seeds { opacity: 1; }
.doodle .stem { stroke: var(--teal); stroke-width: 2.2; }

/* =============================================================
   HERO CARD — a full sunflower that flips over to reveal her photo
   ============================================================= */
.hero-card { padding: 34px 30px 26px; }
.bloom {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  display: block;
  width: min(230px, 80%);
  aspect-ratio: 1;
  margin: 0 auto;
  perspective: 1000px;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
}
.bloom:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; }
.flip {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.34, 1.3, 0.5, 1);
}
.bloom[aria-pressed="true"] .flip { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 50%;
}
.flip-back {
  transform: rotateY(180deg);
  padding: 6px;
  background: conic-gradient(from 200deg, var(--teal), var(--teal-bright), var(--gold), var(--teal));
  box-shadow: 0 18px 34px -18px rgba(35, 40, 45, 0.45);
}
.flip-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 5px solid var(--surface);
  background: var(--bg-warm);
  display: block;
}
.sunflower { width: 100%; height: auto; display: block; filter: drop-shadow(0 12px 18px rgba(201, 138, 38, 0.25)); transition: transform 0.6s var(--ease); }
.sunflower .petals-back { animation: sway 7s ease-in-out infinite; transform-origin: 100px 100px; }
.sunflower .petals-front { animation: sway 7s ease-in-out -3.5s infinite reverse; transform-origin: 100px 100px; }
@keyframes sway { 0%, 100% { rotate: 0deg; } 50% { rotate: 4deg; } }
.bloom:hover .sunflower { transform: rotate(6deg) scale(1.04); }
.card-hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 18px;
  transition: opacity 0.4s var(--ease);
}
.card-hint i { font-size: 12px; margin-left: 4px; color: var(--teal); }

/* =============================================================
   FOOTER — sealed envelope; the contact letter slides out and is written
   ============================================================= */
.foot-stack { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.note-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; }
.mailer {
  position: relative;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.letter-slot {
  width: 100%;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.8s var(--ease);
  margin-bottom: -44px;
  position: relative;
  z-index: 3; /* the unfolded letter rests on top of the envelope */
}
.mailer.open .letter-slot { grid-template-rows: 1fr; }
.letter-card {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -20px 60px -30px rgba(0, 0, 0, 0.6);
  transform: translateY(140px) scale(0.72);
  transform-origin: 50% 100%;
  opacity: 0;
  transition: transform 0.85s var(--ease) 0.05s, opacity 0.5s ease 0.1s;
  text-align: left;
}
.mailer.open .letter-card { transform: none; opacity: 1; }
.letter-inner { padding: 34px 38px 76px; }
.letter-card::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 34px; height: 34px;
  background: linear-gradient(225deg, var(--charcoal) 0 50%, #e4e0d4 50%);
  border-bottom-left-radius: 4px;
}
.letter-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.letter-top .kicker { margin-bottom: 0; color: var(--teal); }
.letter-date { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.letter-card h2 {
  font-size: clamp(22px, 3.2vw, 30px);
  color: var(--ink);
  margin-bottom: 12px;
}
.letter-card h2 em { color: var(--teal); font-style: italic; }
.letter-card p { font-size: 15px; color: var(--ink-2); margin-bottom: 18px; max-width: 50ch; }
.contact-lines { list-style: none; display: grid; gap: 8px; }
.contact-lines li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--ink-2);
}
.contact-lines li i {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: none;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.4s var(--ease), transform 0.5s var(--ease);
}
.contact-lines li.on i { opacity: 1; transform: none; }
.contact-lines a { color: var(--ink-2); }
.contact-lines a:hover { color: var(--teal); }
.letter-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  min-height: 78px;
}
.signature {
  font-family: var(--hand);
  font-weight: 600;
  font-size: 32px;
  line-height: 1;
  color: var(--ink);
  position: relative;
  padding-bottom: 10px;
}
.signature .swoosh { position: absolute; left: -6px; right: -10px; bottom: -2px; height: 14px; overflow: visible; }
.signature .swoosh path { fill: none; stroke: var(--teal); stroke-width: 2.4; stroke-linecap: round; }
.letter-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  pointer-events: none;
}
.letter-card.dry .letter-actions { opacity: 1; transform: none; pointer-events: auto; }
.letter-skip {
  position: absolute;
  right: 38px; bottom: 54px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.4s;
}
.letter-card.dry .letter-skip, .mailer:not(.open) .letter-skip { opacity: 0; }
.btn-fold {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 50px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.btn-fold:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* the envelope (sealed) */
.envelope {
  --w: 300px;
  --h: 198px;
  position: relative;
  z-index: 2;
  width: var(--w);
  height: var(--h);
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 26px 34px rgba(0, 0, 0, 0.35));
  transition: transform 0.45s var(--ease), filter 0.45s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.envelope:hover, .envelope:focus-visible { transform: translateY(-6px); filter: drop-shadow(0 34px 40px rgba(0, 0, 0, 0.4)); }
.mailer.open .envelope:hover { transform: none; }
.envelope:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 12px; }
.envelope > span { position: absolute; display: block; }
.env-back { inset: 0; border-radius: 8px; background: linear-gradient(180deg, #e9e6dc, #dcd8cb); }
.env-letter {
  left: 16px; right: 16px; top: 10px;
  height: 78%;
  border-radius: 4px;
  background: var(--paper);
  background-image: repeating-linear-gradient(180deg, transparent 0 17px, var(--paper-line) 17px 18px);
  transition: transform 0.5s var(--ease), opacity 0.4s ease;
}
.envelope:hover .env-letter { transform: translateY(-10px); }
.mailer.open .env-letter { opacity: 0; }
.env-front {
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(160deg, #f3f1ea 0%, #e6e3d8 100%);
  clip-path: polygon(0 100%, 0 38%, 50% 66%, 100% 38%, 100% 100%);
}
.env-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 49.6%, rgba(35, 40, 45, 0.07) 50%, transparent 50.4%),
              linear-gradient(-115deg, transparent 49.6%, rgba(35, 40, 45, 0.07) 50%, transparent 50.4%);
}
.env-flap {
  left: 0; right: 0; top: 0;
  height: 62%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, #eeebe2, #dad6c9);
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.7s var(--ease), z-index 0s 0.35s;
  z-index: 2;
  backface-visibility: visible;
}
.envelope:hover .env-flap { transform: rotateX(-22deg); }
.mailer.open .env-flap { transform: rotateX(-180deg); z-index: 0; background: linear-gradient(0deg, #e2ded1, #cfcabb); }
.env-seal {
  left: 50%; top: 52%;
  width: 68px; height: 68px;
  transform: translate(-50%, -50%);
  z-index: 3;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  transition: transform 0.5s var(--ease), opacity 0.35s ease;
}
.envelope:hover .env-seal { transform: translate(-50%, -50%) rotate(14deg) scale(1.06); }
.mailer.open .env-seal { opacity: 0; transform: translate(-50%, -50%) rotate(60deg) scale(0.3); }
.env-seal svg { width: 100%; height: 100%; }
.env-label {
  left: 0; right: 0; bottom: 14px;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-2);
  z-index: 2;
  transition: opacity 0.3s;
}
.mailer.open .env-label { opacity: 0; }
.note-hint {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: rgba(236, 234, 227, 0.7);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  transition: opacity 0.4s;
}
.note-hint i { color: var(--gold); }
.mailer.open + .note-hint { opacity: 0; }

/* wobble once when the footer scrolls into view */
.note-wrap.in .envelope, .envelope.nudge { animation: wobble 1.1s var(--ease) 0.3s 1; }
.envelope:hover { animation: none; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg) translateY(-6px); }
  40% { transform: rotate(3deg); }
  60% { transform: rotate(-2deg) translateY(-3px); }
  80% { transform: rotate(1deg); }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
footer .foot-social { margin-top: 0; }

@media (max-width: 600px) {
  .envelope { --w: 236px; --h: 156px; }
  .env-seal { width: 56px; height: 56px; }
  .letter-inner { padding: 26px 20px 72px; }
  .letter-skip { right: 20px; }
  .letter-card p { font-size: 14px; }
  .contact-lines li { font-size: 12.5px; flex-wrap: wrap; }
  .signature { font-size: 27px; }
  .doodle { width: 62px; height: 62px; }
  .quill { width: 42px; height: 106px; }
  .quill--small { width: 34px; height: 86px; }
}

/* Reduced motion: show everything in its finished state */
@media (prefers-reduced-motion: reduce) {
  .hw .c { clip-path: none; opacity: 1; }
  .draw { stroke-dashoffset: 0; }
  .quill { display: none; }
  .contact-lines li i { opacity: 1; transform: none; }
  .note-wrap.in .envelope, .envelope.nudge, .sunflower .petals-back, .sunflower .petals-front { animation: none; }
  .hero-card { animation: none; }
  .flip { transition: none; }
}
