:root {
    color-scheme: dark;
    font-family: "Courier New", Courier, monospace;
    background: #090909;
    color: #d0d0d0;
    --red: #a80d13;
    --paper: #f4ecd7;
    --ink: #211f1b;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 50% 38%, rgb(94 14 16 / 22%), transparent 32rem),
        repeating-linear-gradient(135deg, #0c0c0c 0 3px, #080808 3px 7px);
}

button,
textarea,
input {
    font: inherit;
}

.page-shell {
    width: min(940px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding-bottom: 2rem;
    perspective: 800px;
    background:
        linear-gradient(110deg, transparent 35%, rgb(90 10 12 / 12%) 35% 65%, transparent 65%),
        radial-gradient(ellipse at center 48%, rgb(255 255 255 / 3%), transparent 60%);
}

.masthead {
    padding: 1.2rem 1rem 1rem;
    text-align: center;
    background: rgb(12 12 12 / 90%);
    border-bottom: 1px solid #292929;
}

.brand {
    display: inline-block;
    color: #f4f4f4;
    font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
    font-size: clamp(2.8rem, 8vw, 4.5rem);
    line-height: 1;
    letter-spacing: .025em;
    text-decoration: none;
    transform: rotate(-1deg);
}

.brand span {
    color: #777;
}

.brand strong {
    color: var(--red);
    font-weight: inherit;
}

.masthead > p {
    margin: 1rem 0 .35rem;
    font-size: clamp(.72rem, 2vw, 1rem);
    letter-spacing: .04em;
}

details {
    font-size: .85rem;
}

summary {
    color: #cb2d32;
    cursor: pointer;
    text-transform: uppercase;
}

.explanation {
    max-width: 720px;
    margin: .8rem auto 0;
    text-align: left;
    line-height: 1.5;
}

.instructions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem clamp(1rem, 5vw, 3rem);
    padding: 1rem;
    color: #929292;
    background: rgb(16 16 16 / 86%);
    border: 2px dashed #414141;
    border-radius: .4rem;
}

.instructions div {
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: .84rem;
    line-height: 1.25;
}

.instructions b {
    color: var(--red);
    font-family: Impact, sans-serif;
    font-size: 2.2rem;
    font-weight: 400;
}

.paper {
    --ruler-offset: clamp(4.5rem, 10vw, 6rem);
    --paper-rule: 2rem;
    --paper-line-shift: 0;
    --control-row: calc(var(--paper-rule) + var(--paper-rule));
    --control-height: calc(var(--control-row) - .5rem);
    position: relative;
    min-height: 28rem;
    margin: 1.5rem clamp(1rem, 5vw, 3rem);
    padding-block: var(--paper-rule);
    padding-right: var(--paper-rule);
    padding-left: calc(var(--ruler-offset) + 1.25rem);
    overflow: hidden;
    color: var(--ink);
    font-size: 1rem;
    line-height: var(--paper-rule);
    background-color: #f6eed9;
    background-image: linear-gradient(to bottom, transparent calc(var(--paper-rule) - 1px), #ded5be calc(var(--paper-rule) - 1px) var(--paper-rule));
    background-repeat: repeat;
    background-position: 0 var(--paper-line-shift);
    background-size: 100% var(--paper-rule);
    border-radius: .7rem 1.2rem .8rem 1rem;
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 45%);
    backface-visibility: hidden;
    transform-style: preserve-3d;
    will-change: transform;
}

.paper::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--ruler-offset);
    width: 2px;
    content: "";
    background: rgb(170 13 19 / 15%);
    pointer-events: none;
}

.paper::after {
    position: absolute;
    right: -1.5rem;
    bottom: -1.3rem;
    width: 10rem;
    height: 10rem;
    content: "SECRET";
    display: grid;
    place-items: center;
    color: rgb(168 13 19 / 10%);
    border: .6rem double rgb(168 13 19 / 10%);
    border-radius: 50%;
    font-family: Impact, sans-serif;
    font-size: 2rem;
    transform: rotate(-18deg);
    pointer-events: none;
}

.paper h1 {
    display: block;
    margin: 0 0 var(--paper-rule);
    line-height: var(--paper-rule);
    font-weight: 700;
    text-transform: uppercase;
}

.paper h1 {
    font-size: 1.5rem;
}

.compose-title {
    margin-bottom: 0;
}

.compose-title label {
    display: block;
    cursor: text;
}

.message-box {
    position: relative;
    height: 18rem;
}

.message-box::before,
.warning::before {
    position: absolute;
    inset: .25rem 0;
    content: "";
    pointer-events: none;
}

.message-box::before {
    background: rgb(255 255 255 / 44%);
    border: 1px solid #b8ae98;
    border-radius: .2rem;
}

.message-box textarea {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 0 4.25rem 0 .8rem;
    resize: none;
    color: #161616;
    line-height: var(--paper-rule);
    background: transparent;
    border: 0;
    outline: none;
}

.message-box:focus-within::before,
.copy-row input:focus,
button:focus-visible {
    outline: 3px solid rgb(168 13 19 / 35%);
    outline-offset: 2px;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.primary,
#copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height);
    min-height: var(--control-height);
    padding: 0 1rem;
    color: #eee;
    background: #171717;
    border: 0;
    border-radius: .25rem;
    font-weight: 700;
    line-height: normal;
}

.primary {
    margin-top: 0;
}

.next-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex: none;
    fill: none;
    stroke: #d22229;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.copy-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: var(--control-row);
    gap: .5rem;
}

.copy-row input {
    width: 100%;
    height: var(--control-height);
    min-width: 0;
    padding: 0 .7rem;
    color: #171717;
    background: rgb(255 255 255 / 70%);
    border: 1px solid #a59a82;
}

.paste-button {
    position: absolute;
    z-index: 2;
    right: .75rem;
    bottom: .75rem;
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    place-items: center;
    color: #eee;
    background: #171717;
    border: 1px solid #4d473c;
    border-radius: .25rem;
    box-shadow: 0 .15rem .35rem rgb(0 0 0 / 25%);
}

.paste-button svg {
    width: 1.35rem;
    height: 1.35rem;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

#copy-button {
    min-width: 6.5rem;
    transition: color 120ms ease, background-color 120ms ease;
}

#copy-button.copied {
    color: #fff;
    background: #27643f;
}

.share-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: start;
}

.share-copy h1,
.share-copy p {
    line-height: var(--paper-rule);
}

.share-copy h1 {
    margin-bottom: 0;
}

.share-copy p {
    margin: 0 0 var(--paper-rule);
}

.qr-wrap {
    margin-top: 0;
}

#qr-code {
    display: block;
    width: min(10rem, 48vw);
    height: auto;
    background: white;
    border: .4rem solid white;
}

.warning {
    position: relative;
    isolation: isolate;
    margin: 0 0 var(--paper-rule);
    padding: 1rem;
    color: #f5e9d2;
    background: transparent;
}

.warning::before {
    z-index: -1;
    background: #7f0c10;
    border-radius: .3rem;
}

.warning h1,
.warning p {
    margin: 0;
}

.warning p {
    margin-top: 0;
    line-height: var(--paper-rule);
}

.cleartext {
    min-height: 14rem;
    padding: 0 .8rem;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    line-height: var(--paper-rule);
    background-image: linear-gradient(rgb(255 255 255 / 35%), rgb(255 255 255 / 35%));
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% calc(100% - .5rem);
}

.cleartext a {
    color: #780b0f;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    min-height: var(--control-row);
    gap: var(--paper-rule);
    margin-top: var(--paper-rule);
}

#status {
    position: relative;
    z-index: 1;
    min-height: var(--paper-rule);
    margin-top: var(--paper-rule);
    line-height: var(--paper-rule);
    font-weight: 700;
}

#status.error {
    color: #9a0b10;
}

[hidden] {
    display: none !important;
}

@media (max-width: 680px) {
    .instructions {
        grid-template-columns: 1fr;
        gap: .2rem;
    }

    .paper {
        padding-left: var(--paper-rule);
    }

    .paper::before {
        display: none;
    }

    .share-layout {
        grid-template-columns: 1fr;
        gap: var(--paper-rule);
    }

    .qr-wrap {
        margin-top: 0;
        justify-self: center;
    }

    .copy-row {
        grid-template-columns: 1fr;
        grid-auto-rows: var(--control-row);
        gap: 0;
    }

    #copy-button,
    .action-row button {
        width: 100%;
    }

    .action-row {
        display: grid;
        grid-template-columns: 1fr;
        grid-auto-rows: var(--control-row);
        gap: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .paper {
        will-change: auto;
    }
}
