/*
 * MailerEnergy — "posta italiana"
 * Paper, ink and vermilion; Bodoni for display (Parma, 1798), Figtree for
 * reading, IBM Plex Mono for postal labels. Signature pieces: the postage
 * stamp, the airmail envelope border and the postmark.
 */
:root {
    --paper: #F4EEE3;
    --paper-deep: #EAE1D1;
    --card: #FFFDF8;
    --ink: #1B1A17;
    --ink-soft: #4A463F;
    --muted: #6B6459;
    --rule: #D9CEBB;
    --red: #C8321A;          /* buttons, stamps (white text 5.4:1) */
    --red-ink: #B02A14;      /* red text on paper (5.7:1) */
    --airmail-blue: #1F3A68;
    --stamp-green: #2F5D46;
    --font-display: 'Bodoni Moda', 'Didot', 'Bodoni 72', Georgia, serif;
    --font-body: 'Figtree', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

/* ---- Base ------------------------------------------------------------- */
html { background: var(--paper); }
body.me-site {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    /* faint paper grain */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.3 0 0 0 0 0.22 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.me-site h1, .me-site h2, .me-display {
    font-family: var(--font-display);
    font-optical-sizing: auto;
    letter-spacing: -0.015em;
}
.me-site h1 { font-weight: 700; line-height: 1.02; }
.me-site h2 { font-weight: 600; }
.me-site h1 em, .me-site h2 em, .me-display em { font-style: italic; color: var(--red-ink); font-weight: 500; }
.me-site ::selection { background: var(--red); color: #fff; }
.me-site a:focus-visible, .me-site button:focus-visible, .me-site input:focus-visible, .me-site textarea:focus-visible {
    outline: 2px solid var(--airmail-blue); outline-offset: 2px;
}
.me-site input[type=text], .me-site input[type=email], .me-site input:not([type]), .me-site textarea {
    background: var(--card); border-color: var(--rule);
}

/* Prices: small optical size keeps Bodoni's hairlines thick enough that a 4 never reads as a 1. */
.me-price { font-family: var(--font-display); font-weight: 800; font-variation-settings: 'opsz' 11; font-optical-sizing: none; letter-spacing: -0.02em; }

/* ---- Labels & rules ---------------------------------------------------- */
.me-label {
    font-family: var(--font-mono);
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}
.me-label--red { color: var(--red-ink); }
.me-rule { border: 0; border-top: 1px solid var(--rule); }
.me-rule--double { border: 0; height: 5px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.me-mono { font-family: var(--font-mono); }

/* ---- Buttons (legacy .grad kept as the primary button) ------------------ */
.grad, .me-btn {
    background: var(--red) !important;
    color: #fff !important;
    border: 1.5px solid var(--ink);
    box-shadow: 3px 3px 0 0 var(--ink) !important;
    transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.grad:hover, .me-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--ink) !important; }
.grad:active, .me-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 var(--ink) !important; }
.me-btn--ghost {
    background: transparent !important; color: var(--ink) !important;
    border: 1.5px solid var(--ink); box-shadow: none !important;
}
.me-btn--ghost:hover { background: var(--ink) !important; color: var(--paper) !important; }
.grad-text { color: var(--red-ink); font-family: var(--font-display); font-style: italic; background: none; -webkit-text-fill-color: currentColor; }

/* ---- Cards ------------------------------------------------------------ */
.me-card { background: var(--card); border: 1px solid var(--rule); }
.me-card--ink { border-color: var(--ink); box-shadow: 4px 4px 0 0 var(--ink); }

/* ---- Postage stamp (perforated edge) ------------------------------------ */
.me-stamp {
    --r: 4px;   /* perforation hole radius */
    --s: 12px;  /* distance between holes */
    position: relative;
    display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 20px 24px;
    background: var(--red);
    color: #fff;
    /* holes along every edge; the inner rectangle stays solid */
    -webkit-mask:
        radial-gradient(var(--r), #0000 97%, #000) round calc(var(--s) / -2) calc(var(--s) / -2) / var(--s) var(--s),
        linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--s)) calc(100% - var(--s));
    mask:
        radial-gradient(var(--r), #0000 97%, #000) round calc(var(--s) / -2) calc(var(--s) / -2) / var(--s) var(--s),
        linear-gradient(#000 0 0) no-repeat 50% / calc(100% - var(--s)) calc(100% - var(--s));
}
.me-stamp::before { /* inner frame */
    content: ""; position: absolute; inset: 9px; border: 1px solid rgba(255, 255, 255, .55); pointer-events: none;
}
.me-stamp__value { font-family: var(--font-display); font-weight: 800; font-variation-settings: 'opsz' 11; font-size: 2.6rem; line-height: 1; }
.me-stamp__caption { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; margin-top: 6px; }
.me-stamp--green { background: var(--stamp-green); }
.me-stamp--blue { background: var(--airmail-blue); }

/* ---- Airmail envelope border ------------------------------------------ */
.me-airmail {
    position: relative;
    background: var(--card);
    border: 9px solid transparent;
    border-image: repeating-linear-gradient(-45deg,
        var(--red) 0 12px, var(--card) 12px 18px,
        var(--airmail-blue) 18px 30px, var(--card) 30px 36px) 9;
}

/* ---- Postmark ---------------------------------------------------------- */
.me-postmark { color: var(--airmail-blue); opacity: .85; }
.me-postmark text { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 2.4px; text-transform: uppercase; fill: currentColor; }

/* ---- Load choreography -------------------------------------------------- */
@keyframes me-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes me-slide { from { opacity: 0; transform: translate(40px, 10px) rotate(4deg); } to { opacity: 1; transform: rotate(-2deg); } }
@keyframes me-thunk { 0% { opacity: 0; transform: scale(1.6) rotate(-14deg); } 70% { opacity: 1; transform: scale(.96) rotate(5deg); } 100% { opacity: 1; transform: scale(1) rotate(6deg); } }
@keyframes me-stampink { from { opacity: 0; transform: scale(1.25) rotate(-30deg); } to { opacity: .85; transform: scale(1) rotate(-12deg); } }
.me-rise { opacity: 0; animation: me-rise .7s cubic-bezier(.2, .7, .2, 1) forwards; }
.me-d1 { animation-delay: .08s; } .me-d2 { animation-delay: .18s; } .me-d3 { animation-delay: .3s; } .me-d4 { animation-delay: .44s; }
.me-envelope-in { opacity: 0; animation: me-slide .9s cubic-bezier(.2, .7, .2, 1) .25s forwards; }
.me-stamp-in { opacity: 0; animation: me-thunk .55s cubic-bezier(.3, 1.4, .5, 1) 1s forwards; }
.me-postmark-in { opacity: 0; animation: me-stampink .45s ease-out 1.35s forwards; }

@media (prefers-reduced-motion: reduce) {
    .me-rise, .me-envelope-in, .me-stamp-in, .me-postmark-in { animation: none !important; opacity: 1 !important; }
    .me-envelope-in { transform: rotate(-2deg); }
    .me-stamp-in { transform: rotate(6deg); }
    .me-postmark-in { opacity: .85 !important; transform: rotate(-12deg); }
    .grad, .me-btn { transition: none; }
}

/* ---- Guide article typography ------------------------------------------ */
.prose-doc h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; margin: 1.8rem 0 .6rem; color: var(--ink); }
.prose-doc p { margin: .75rem 0; line-height: 1.75; color: var(--ink-soft); }
.prose-doc ul, .prose-doc ol { margin: .75rem 0 .75rem 1.3rem; line-height: 1.75; color: var(--ink-soft); }
.prose-doc ul { list-style: square; } .prose-doc ol { list-style: decimal; }
.prose-doc li { margin: .35rem 0; }
.prose-doc code { font-family: var(--font-mono); font-size: .84em; background: var(--paper-deep); color: var(--red-ink); padding: .1rem .35rem; }
.prose-doc b { color: var(--ink); }
.prose-doc a { color: var(--red-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
