/* =====================================================
   Historic Atelier v1.0 — Frontend CSS
   Seven crafts: Gutenberg · Calligraphy · Cyanotype
                 Pottery · Darkroom · Daguerreotype · Fossil
   ===================================================== */

/* ── Custom Properties ──────────────────────────────── */
.historic-atelier-widget {
    --ha-phase-active:  #c17c2a;
    --ha-phase-done:    #7a9a5a;
    --ha-paper:         #f5efdc;
    --ha-ink:           #1a1008;
    --ha-accent:        #8b4513;
    --ha-radius:        4px;
    font-family: 'Georgia','Times New Roman',serif;
}

/* ── Craft colour themes ─────────────────────────────── */
.craft-gutenberg    { --ha-phase-active:#8b2500; }
.craft-calligraphy  { --ha-phase-active:#1a3a6a; }
.craft-cyanotype    { --ha-phase-active:#1c4e80; }
.craft-pottery      { --ha-phase-active:#a05020; }
.craft-darkroom     { --ha-phase-active:#8b0000; }
.craft-daguerreotype{ --ha-phase-active:#a08020; }
.craft-fossil       { --ha-phase-active:#6a5030; }

/* ══════════════════════════════════════════════════════
   CRAFT SELECTION BAR
   ══════════════════════════════════════════════════════ */
.ha-craft-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.ha-craft-btn {
    background: rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.12);
    color: #5a4a35;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-family: 'Georgia', serif;
    font-style: italic;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.ha-craft-btn:hover {
    background: rgba(0,0,0,0.12);
    color: #2a1f0e;
}
.ha-craft-btn.active {
    background: var(--ha-phase-active);
    border-color: var(--ha-phase-active);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.ha-craft-desc {
    font-size: 0.82rem;
    color: #7a6a55;
    font-style: italic;
    margin-bottom: 18px;
    line-height: 1.45;
    min-height: 1.45em;
    transition: opacity 0.3s ease;
}

/* ══════════════════════════════════════════════════════
   GRID
   ══════════════════════════════════════════════════════ */
.ha-grid { display: grid; gap: 28px; }
.ha-cols-1 { grid-template-columns: 1fr; }
.ha-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ha-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ha-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) { .ha-cols-3,.ha-cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px) { .ha-cols-2,.ha-cols-3,.ha-cols-4 { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════════════
   SURFACE WRAPPER
   ══════════════════════════════════════════════════════ */
.ha-surface-wrapper {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: var(--ha-radius);
    overflow: hidden;
    cursor: crosshair;
    box-shadow:
        0 2px 8px rgba(0,0,0,0.18),
        0 8px 24px rgba(0,0,0,0.10),
        inset 0 1px 0 rgba(255,255,255,0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.ha-surface-wrapper:hover {
    box-shadow:
        0 4px 16px rgba(0,0,0,0.25),
        0 16px 40px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* Craft-specific backgrounds (canvas renders on top) */
.craft-gutenberg     .ha-surface-wrapper { background: #5a3010; }
.craft-calligraphy   .ha-surface-wrapper { background: #f0e8cc; }
.craft-cyanotype     .ha-surface-wrapper { background: #e8e4d0; }
.craft-pottery       .ha-surface-wrapper { background: #2a1e12; }
.craft-darkroom      .ha-surface-wrapper { background: #1a0808; }
.craft-daguerreotype .ha-surface-wrapper { background: #c0b890; }
.craft-fossil        .ha-surface-wrapper { background: #a08060; }

/* ── Canvas Stack ───────────────────────────────────── */
.ha-canvas-stack { position: absolute; inset: 0; }
.ha-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    display: block; pointer-events: none;
}
/* Layer z-order */
.ha-canvas[data-layer="base"]    { z-index: 1; }
.ha-canvas[data-layer="tool"]    { z-index: 2; mix-blend-mode: multiply; }
.ha-canvas[data-layer="process"] { z-index: 3; mix-blend-mode: overlay; }
.ha-canvas[data-layer="reveal"]  { z-index: 4; }
.ha-canvas[data-layer="finish"]  { z-index: 5; }
.ha-canvas[data-layer="aging"]   { z-index: 6; mix-blend-mode: multiply; pointer-events: none; }
.ha-canvas[data-layer="drying"]  { z-index: 7; mix-blend-mode: screen;   pointer-events: none; }

/* Cyanotype: process layer is deep blue overlay */
.craft-cyanotype .ha-canvas[data-layer="process"] { mix-blend-mode: normal; }
/* Darkroom: reveal is soft-light */
.craft-darkroom  .ha-canvas[data-layer="reveal"]  { mix-blend-mode: soft-light; }

/* ── Phase Dots ─────────────────────────────────────── */
.ha-phase-indicator {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 5px; z-index: 20;
    background: rgba(0,0,0,0.38); padding: 4px 9px; border-radius: 20px;
    backdrop-filter: blur(4px);
}
.ha-phase-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: rgba(255,255,255,0.28);
    border: 1px solid rgba(255,255,255,0.4);
    transition: all 0.3s ease; cursor: pointer;
}
.ha-phase-dot.active { background: var(--ha-phase-active); border-color: var(--ha-phase-active); box-shadow: 0 0 6px var(--ha-phase-active); transform: scale(1.3); }
.ha-phase-dot.done   { background: var(--ha-phase-done);   border-color: var(--ha-phase-done); }

/* ── Phase Label ────────────────────────────────────── */
.ha-phase-label {
    position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
    z-index: 20; pointer-events: none;
}
.ha-phase-label span {
    display: inline-block;
    background: rgba(0,0,0,0.52); color: rgba(255,255,255,0.92);
    font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    padding: 3px 9px; border-radius: 12px;
    backdrop-filter: blur(4px); font-style: italic; white-space: nowrap;
}

/* ── Tool Cursor ────────────────────────────────────── */
.ha-tool-cursor {
    position: absolute; width: 26px; height: 26px; z-index: 15;
    transform: translate(-50%,-50%); pointer-events: none;
    opacity: 0; transition: opacity 0.2s ease;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55));
}
.ha-tool-cursor.visible { opacity: 1; }
.ha-tool-cursor svg { width: 100%; height: 100%; }

/* Craft cursor colours */
.craft-gutenberg     .ha-tool-cursor { color: #1a0808; }
.craft-calligraphy   .ha-tool-cursor { color: #1a1860; }
.craft-cyanotype     .ha-tool-cursor { color: #c8c000; }
.craft-pottery       .ha-tool-cursor { color: #d0b090; }
.craft-darkroom      .ha-tool-cursor { color: #ff3030; }
.craft-daguerreotype .ha-tool-cursor { color: #e0d080; }
.craft-fossil        .ha-tool-cursor { color: #d0c0a0; }

/* ── Phase Nav ──────────────────────────────────────── */
.ha-phase-nav {
    position: absolute; bottom: 10px; right: 10px;
    display: flex; gap: 5px; z-index: 20;
    opacity: 0; transition: opacity 0.3s ease;
}
.ha-surface-wrapper:hover .ha-phase-nav { opacity: 1; }
.ha-prev-phase, .ha-next-phase {
    width: 26px; height: 26px; border: none;
    background: rgba(0,0,0,0.45); color: #fff;
    font-size: 0.8rem; cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px); transition: background 0.2s;
}
.ha-prev-phase:hover, .ha-next-phase:hover { background: rgba(0,0,0,0.7); }

/* ── Click Hint ─────────────────────────────────────── */
.ha-click-hint {
    position: absolute; bottom: 10px; left: 10px; z-index: 20;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.ha-surface-wrapper:hover .ha-click-hint { opacity: 1; }
.ha-click-hint span {
    font-size: 10px; color: rgba(255,255,255,0.82);
    background: rgba(0,0,0,0.45); padding: 3px 8px;
    border-radius: 10px; font-style: italic;
}

/* ── Caption ────────────────────────────────────────── */
.ha-item-caption { padding: 10px 2px 4px; }
.ha-item-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.ha-item-title { font-size: 1rem; font-weight: 600; margin: 0; color: #2a1f0e; font-style: italic; }
.ha-item-year  { font-size: 0.75rem; color: #9a7a55; letter-spacing: 0.5px; }
.ha-item-desc  { font-size: 0.8rem; color: #5a4a35; margin: 0; line-height: 1.4; }

/* ── Entry animation ────────────────────────────────── */
.ha-item { animation: haItemIn 0.65s ease forwards; opacity: 0; transform: translateY(18px); }
@keyframes haItemIn { to { opacity:1; transform:translateY(0); } }
.ha-item:nth-child(1){animation-delay:.00s} .ha-item:nth-child(2){animation-delay:.09s}
.ha-item:nth-child(3){animation-delay:.18s} .ha-item:nth-child(4){animation-delay:.27s}
.ha-item:nth-child(5){animation-delay:.36s} .ha-item:nth-child(6){animation-delay:.45s}
.ha-item:nth-child(7){animation-delay:.54s} .ha-item:nth-child(8){animation-delay:.63s}

/* ══════════════════════════════════════════════════════
   LIGHTBOX
   ══════════════════════════════════════════════════════ */
.ha-lightbox {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.35s ease;
}
.ha-lightbox.open { opacity: 1; pointer-events: all; }

.ha-lb-backdrop {
    position: absolute; inset: 0;
    background: rgba(8,5,2,0.93); backdrop-filter: blur(8px); cursor: pointer;
}

.ha-lb-container {
    position: relative; z-index: 1;
    width: min(90vw, 900px); max-height: 90vh;
    display: flex; align-items: center; justify-content: center;
}

/* Canvas wrap (slides away) */
.ha-lb-canvas-wrap {
    position: absolute; inset: 0; z-index: 2;
    border-radius: 6px; overflow: hidden;
}
.ha-lb-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
}

/* Result */
.ha-lb-result {
    position: relative; z-index: 3; width: 100%;
    background: var(--ha-paper); border-radius: 4px; overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 20px 80px rgba(0,0,0,0.65);
}
.ha-lb-image {
    display: block; width: 100%; max-height: 62vh; object-fit: contain;
    transition: filter 0.5s ease; mix-blend-mode: multiply;
}
.ha-lb-aging-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none; mix-blend-mode: multiply;
}
.ha-lb-grain {
    position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* ── LB UI ──────────────────────────────────────────── */
.ha-lb-ui { position: absolute; inset: 0; z-index: 10; pointer-events: none; }

.ha-lb-close {
    position: absolute; top: -44px; right: 0;
    width: 36px; height: 36px; border: none;
    background: rgba(255,255,255,0.1); color: #fff; cursor: pointer;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    pointer-events: all; backdrop-filter: blur(4px); transition: background 0.2s;
}
.ha-lb-close:hover { background: rgba(255,255,255,0.25); }
.ha-lb-close svg { width: 20px; height: 20px; }

.ha-lb-caption {
    position: absolute; bottom: -80px; left: 0; right: 0;
    text-align: center; pointer-events: none;
}
.ha-lb-craft-name {
    font-size: 0.65rem; letter-spacing: 2px; text-transform: uppercase;
    color: var(--ha-phase-active); margin-bottom: 3px; font-style: normal;
}
.ha-lb-title { font-size: 1.05rem; color: rgba(255,255,255,0.92); margin: 0 0 3px; font-style: italic; }
.ha-lb-desc  { font-size: 0.78rem; color: rgba(255,255,255,0.58); margin: 0 0 2px; }
.ha-lb-year  { font-size: 0.72rem; color: rgba(255,255,255,0.45); letter-spacing: 0.5px; }

.ha-lb-nav {
    position: absolute; top: 50%; left: -50px; right: -50px;
    transform: translateY(-50%); display: flex; justify-content: space-between;
    pointer-events: all;
}
.ha-lb-prev, .ha-lb-next {
    width: 38px; height: 38px; border: none;
    background: rgba(255,255,255,0.12); color: #fff; font-size: 1.2rem;
    cursor: pointer; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px); transition: background 0.2s;
}
.ha-lb-prev:hover,.ha-lb-next:hover { background: rgba(255,255,255,0.28); }

.ha-lb-phases {
    position: absolute; top: -52px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 5px; pointer-events: all;
    flex-wrap: wrap; justify-content: center;
}
.ha-lb-phase-btn {
    background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.62);
    border: 1px solid rgba(255,255,255,0.2); padding: 4px 10px; font-size: 0.68rem;
    cursor: pointer; border-radius: 16px; font-family: 'Georgia', serif; font-style: italic;
    transition: all 0.2s; backdrop-filter: blur(4px); white-space: nowrap;
}
.ha-lb-phase-btn:hover { background: rgba(255,255,255,0.22); color: rgba(255,255,255,0.9); }
.ha-lb-phase-btn.active { background: var(--ha-phase-active); border-color: var(--ha-phase-active); color: #fff; }

/* Aging row */
.ha-lb-aging-row {
    position: absolute; bottom: -50px; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 8px; pointer-events: all;
    color: rgba(255,255,255,0.55); font-size: 0.72rem; font-style: italic; white-space: nowrap;
}
.ha-lb-aging-slider { width: 90px; height: 3px; accent-color: var(--ha-phase-active); cursor: pointer; }

/* Gyro prompt */
.ha-gyro-prompt {
    position: absolute; bottom: -90px; left: 50%; transform: translateX(-50%);
    pointer-events: all; text-align: center;
}
.ha-gyro-btn {
    background: rgba(193,124,42,0.8); color: #fff; border: none;
    padding: 7px 16px; border-radius: 20px; cursor: pointer;
    font-size: 0.78rem; backdrop-filter: blur(4px); transition: background 0.2s;
}
.ha-gyro-btn:hover { background: rgba(193,124,42,1); }

@media (max-width: 768px) {
    .ha-lb-nav { left: -4px; right: -4px; }
    .ha-lb-phases { top: auto; bottom: -58px; }
    .ha-lb-caption { bottom: -110px; }
    .ha-lb-aging-row { bottom: -80px; }
}

/* ── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ha-item { animation: none; opacity: 1; transform: none; }
    .ha-surface-wrapper { transition: none; }
}
