/* /card — the envelope a gift card arrives in */
.co-page { margin: 0; min-height: 100vh; background: radial-gradient(120% 70% at 50% 18%, #fffdf6 0%, var(--cream, #faf7ef) 60%, #f1ece0 100%); color: var(--text, #646869); overflow-x: hidden; }
.co, .co-overlay { --ew: min(86vw, 400px); --eh: calc(var(--ew) / 1.4); }
.co { max-width: 560px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 16px 64px; }
.co-logo { display: block; width: 150px; margin: 6px auto 0; }
.co-logo img { display: block; width: 100%; height: auto; }

.co-scene, .co-preview-scene { position: relative; display: grid; justify-items: center; align-content: center; min-height: calc(100svh - 120px); padding: 40px 0 24px; }
.co-scene.is-open, .co-preview-scene.is-open { min-height: 0; padding-top: 28px; }
.co-scene:empty { display: none; }

/* Envelope */
.co-envelope { position: relative; display: block; width: var(--ew); height: var(--eh); margin-top: calc(var(--eh) * .5); padding: 0; border: 0; background: none; cursor: pointer; perspective: 1200px; -webkit-tap-highlight-color: transparent; animation: co-float 4.5s ease-in-out infinite; }
.co-envelope:focus-visible { outline: 3px solid var(--action, #5b9db9); outline-offset: 10px; border-radius: 10px; }
.co-envelope.is-opening { animation: none; cursor: default; }
.co-envelope[hidden] { display: none; }
.co-envelope > span { position: absolute; display: block; }
.co-back { inset: 0; border-radius: 10px; background: #d8c4a3; box-shadow: 0 30px 50px -26px rgba(18, 63, 74, .45); }
.co-slot { left: 0; right: 0; bottom: 5px; height: 400%; overflow: hidden; z-index: 2; }
.co-card { position: absolute; left: 7%; width: 86%; top: calc(100% - var(--eh) * .93); border-radius: 8px; overflow: hidden; box-shadow: 0 10px 24px -14px rgba(18, 63, 74, .5); }
.co-card canvas { display: block; width: 100%; height: auto; }
.co-pocket { inset: 0; z-index: 3; border-radius: 10px; background: linear-gradient(160deg, #f0e4d0, #e6d6bb); clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%); }
.co-pocket::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(18, 63, 74, .07) 50%, transparent calc(50% + 1px)) left bottom / 50% 100% no-repeat, linear-gradient(to top left, transparent calc(50% - 1px), rgba(18, 63, 74, .07) 50%, transparent calc(50% + 1px)) right bottom / 50% 100% no-repeat; }
.co-to { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font: italic 400 clamp(22px, 6vw, 28px)/1.1 "Fraunces Refined", Georgia, serif; color: var(--forest, #123f4a); padding: 0 12%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-flap { left: 0; right: 0; top: 0; height: 62%; z-index: 4; background: linear-gradient(180deg, #e9dbc3, #ddc9a8); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0; border-radius: 10px 10px 0 0; }
.co-flap.is-behind { z-index: 1; }
.co-seal { z-index: 5; left: 50%; top: 62%; width: 54px; height: 54px; margin: -32px 0 0 -27px; display: grid !important; place-items: center; border-radius: 50%; background: var(--action, #5b9db9); box-shadow: 0 6px 14px -6px rgba(18, 63, 74, .55), inset 0 0 0 3px rgba(255, 255, 255, .25); }
.co-seal svg { width: 24px; height: 24px; fill: #fff; }

.co-tap { margin: 34px 0 0; font: 500 12px/1 "DM Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--forest, #123f4a); animation: co-pulse 2.4s ease-in-out infinite; }
.co-tap[hidden] { display: none; }

/* Opened */
.co-final { width: min(86vw, 420px, calc((100svh - 230px) * .8)); }
.co-final:empty { display: none; }
.co-final .co-card { position: relative; left: auto; top: auto; width: 100%; border-radius: 14px; box-shadow: 0 28px 50px -26px rgba(18, 63, 74, .55); cursor: pointer; }
.co-final .co-card canvas { border-radius: 14px; }
.gm-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .6s; }
.gm-fx.is-on { opacity: 1; }
.gm-burst { position: fixed; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none; z-index: 60; }
.gm-burst svg { display: block; width: 100%; height: 100%; }

.co-after, .co-missing { text-align: center; max-width: 440px; margin: 8px auto 0; animation: co-rise .7s .35s both cubic-bezier(.2, .8, .3, 1); }
.co-missing { margin-top: 28vh; animation-delay: 0s; }
.co-after[hidden], .co-missing[hidden], .co-scene[hidden] { display: none; }
.co-after h1, .co-missing h1 { margin: 22px 0 8px; font: 500 clamp(26px, 7vw, 32px)/1.12 "Fraunces Refined", Georgia, serif; letter-spacing: -.01em; color: var(--heading, #717576); }
.co-after p, .co-missing p { margin: 0 auto; font-size: 16px; line-height: 1.55; color: var(--text, #646869); }
.co-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.co-btn { flex: 1 1 160px; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 12px 18px; border: 1.5px solid var(--action, #5b9db9); border-radius: 9px; background: var(--action, #5b9db9); color: #fff; font: 500 12px/1.3 "DM Mono", ui-monospace, monospace; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; cursor: pointer; transition: background .15s, transform .15s; }
.co-btn:hover { background: var(--action-hover, #4f8ea9); }
.co-btn:active { transform: scale(.97); }
.co-btn-quiet { background: transparent; color: var(--action, #5b9db9); }
.co-btn-quiet:hover { background: var(--glacier-wash, #e6f0f3); }
.co-missing .co-btn { margin: 22px 4px 0; max-width: 280px; }
.co-missing .co-btn[hidden] { display: none; }
.co-make { display: inline-block; margin-top: 18px; color: var(--action, #5b9db9); font-size: 15px; text-underline-offset: 3px; }

@keyframes co-float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-7px) rotate(1deg); } }
@keyframes co-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes co-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .co-envelope, .co-tap, .co-after, .co-missing { animation: none; }
}

/* Preview on /gift: the same envelope, full screen */
.co-overlay { position: fixed; inset: 0; z-index: 200; overflow-y: auto; background: radial-gradient(120% 70% at 50% 18%, #fffdf6 0%, #faf7ef 60%, #f1ece0 100%); animation: co-fade .25s ease-out; }
.co-overlay-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: rgba(250, 247, 239, .9); backdrop-filter: blur(8px); }
.co-overlay-bar p { margin: 0; font: 500 11px/1.3 "DM Mono", ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--forest, #123f4a); }
.co-overlay-close { min-height: 38px; padding: 8px 14px; border: 1.5px solid var(--line, #dedccf); border-radius: 999px; background: #fff; color: var(--forest, #123f4a); font: 500 11px/1 "DM Mono", ui-monospace, monospace; letter-spacing: .05em; text-transform: uppercase; cursor: pointer; }
.co-overlay-close:hover { border-color: var(--action, #5b9db9); }
.co-preview-scene { min-height: calc(100svh - 150px); padding: 20px 16px 24px; }
.co-overlay-after { max-width: 440px; margin: 0 auto; padding: 0 16px 48px; text-align: center; animation: co-rise .7s .35s both cubic-bezier(.2, .8, .3, 1); }
.co-overlay-after[hidden] { display: none; }
.co-overlay-after p { margin: 18px 0 16px; font-size: 16px; line-height: 1.5; color: var(--text, #646869); }
.co-overlay-after .co-btn { max-width: 300px; margin: 0 auto; }
@keyframes co-fade { from { opacity: 0; } to { opacity: 1; } }
body.co-locked { overflow: hidden; }
