/* style.css - design tokens from meigen-ai.md, plus bespoke pieces
   (crop marquee, QR frame, upload dropzone) that don't map cleanly to
   Tailwind utility classes. Tailwind (CDN) handles everything else via
   the tailwind.config in index.php. */

:root {
    --color-primary: #4B5563;   /* Graphite Slate */
    --color-accent: #60A5FA;    /* Sky Blue */
    --color-surface: #FFFFFF;   /* Pure White */
    --color-text: #1B1B1B;      /* Charcoal Ink */
    --color-border: #94A3B8;    /* Mist Slate */
    --radius-micro: 6px;
    --radius-standard: 10px;
    --radius-large: 16px;
    --space-unit: 6px;
}

body {
    font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
    color: var(--color-text);
    background: var(--color-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.font-heading {
    font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
}

/* --- Upload dropzone --- */
.dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-large);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.dropzone.dragover {
    border-color: var(--color-accent);
    background-color: #EFF6FF;
}

/* --- QR frame --- */
.qr-frame {
    background: var(--color-surface);
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-standard);
    padding: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.qr-frame canvas {
    display: block;
    border-radius: var(--radius-micro);
}

/* --- Size option cards --- */
.size-card {
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-standard);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    cursor: pointer;
}
.size-card:hover:not(.size-card--disabled) {
    border-color: var(--color-accent);
}
.size-card--selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
}
.size-card--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

/* --- Paper type cards --- */
.paper-card {
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-standard);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.paper-card:hover { border-color: var(--color-accent); }
.paper-card--selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px var(--color-accent);
}

/* --- Crop tool --- */
.crop-stage {
    position: relative;
    display: inline-block;
    user-select: none;
    line-height: 0;
    border-radius: var(--radius-standard);
    overflow: hidden;
    background: #0f172a;
    /* preventDefault() on pointerdown (see crop.js) isn't reliably enough
       on its own to suppress the browser's default pan/zoom touch gestures
       on every mobile browser - this is the belt-and-suspenders CSS fix. */
    touch-action: none;
}
.crop-stage canvas {
    display: block;
    max-width: 100%;
    height: auto;
}
.crop-dim {
    position: absolute;
    background: rgba(15, 23, 42, 0.6);
    pointer-events: none;
}
.crop-marquee {
    position: absolute;
    border: 2px solid #FFFFFF;
    cursor: move;
    box-sizing: border-box;
    touch-action: none;
}
.crop-handle {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #FFFFFF;
    border: 2px solid var(--color-accent);
    border-radius: 4px;
    transform: translate(-50%, -50%);
    touch-action: none;
    /* 24px, not the usual ~44px touch-target guidance: a crop tool is a
       precision control, and handles this large actively hurt fine-grained
       resizing on a small canvas - this is a deliberate tradeoff, roughly
       what native photo-crop tools use for the same reason. */
}
.crop-handle--nw { top: 0; left: 0; cursor: nwse-resize; }
.crop-handle--ne { top: 0; left: 100%; cursor: nesw-resize; }
.crop-handle--sw { top: 100%; left: 0; cursor: nesw-resize; }
.crop-handle--se { top: 100%; left: 100%; cursor: nwse-resize; }

/* --- Misc --- */
.pill { border-radius: 9999px; }
.chip-warning {
    background: #FEF3C7;
    color: #92400E;
    border-radius: 9999px;
}

/* Deliberately a plain !important rule, not reused via Tailwind's `hidden`
   utility: `hidden` would lose to the `sm:flex` responsive variant already
   on #mobile-upload-card at wider viewports, since both are single-class
   selectors and Tailwind's generated stylesheet order would let sm:flex
   win regardless of which class was added later in the HTML. Used by
   app.js's init() to force-hide the QR card when arriving via ?session=
   (a QR scan), independent of viewport width. */
.force-hidden { display: none !important; }

/* Collapses #upload-state to a single centered column once the QR card is
   force-hidden, so the remaining upload card doesn't look like an
   orphaned half-width box in what was a two-column grid. */
#upload-state.single-upload-mode {
    grid-template-columns: 1fr;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
