/* Tapestry v4 — one generated Great Cloth with label-only project feedback. */

body.overview-v2 {
    background: #201a13;
    overflow: hidden;
}

body.overview-v2 #scroller,
body.overview-v2 #thread,
body.overview-v2 #scenes-tab {
    visibility: hidden;
    pointer-events: none;
}

#tapestry-overview {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    overflow: auto;
    overscroll-behavior: contain;
    padding: clamp(8px, 2.2vw, 28px);
    background:
        radial-gradient(ellipse at 50% 38%, rgba(91,72,43,.24), transparent 58%),
        repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 6px),
        linear-gradient(145deg, #18130f, #2b2117 52%, #17120e);
}

#tapestry-overview.is-opening { pointer-events: none; }

.overview-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.great-cloth {
    position: relative;
    width: min(96vw, calc(94svh * 1.30));
    flex: none;
    background: #d0bf97;
    border: clamp(5px, .52vw, 9px) solid #58452d;
    outline: 2px solid #a84230;
    outline-offset: -5px;
    box-shadow:
        0 2.2vh 5vh rgba(0,0,0,.58),
        0 4px 0 rgba(235,220,181,.28) inset,
        0 -5px 0 rgba(59,43,27,.2) inset;
    isolation: isolate;
}

.great-cloth::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 8;
    pointer-events: none;
    opacity: .13;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.065' numOctaves='3' seed='17'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.46'/%3E%3C/svg%3E");
}

.great-cloth::after {
    content: '';
    position: absolute;
    inset: -1px;
    z-index: 9;
    pointer-events: none;
    border: 2px dashed rgba(237,221,181,.72);
    box-shadow: inset 0 0 0 3px rgba(88,69,45,.48);
}

.cloth-name {
    position: relative;
    z-index: 2;
    aspect-ratio: 1983 / 360;
    overflow: hidden;
    background: #d0bf97;
    border-bottom: 3px solid #8b3326;
    box-shadow: inset 0 -1px 0 #eadcbb;
}

.nameplate-art {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    user-select: none;
    -webkit-user-drag: none;
}

.cloth-index {
    position: absolute;
    z-index: 12;
    right: clamp(7px, 1vw, 14px);
    top: 50%;
    width: clamp(34px, 3vw, 44px);
    aspect-ratio: 1;
    display: grid;
    place-content: center;
    gap: 4px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: rgba(224,207,169,.78);
    border: 1.5px dashed rgba(124,45,31,.82);
    box-shadow: inset 0 0 0 3px rgba(244,234,210,.46), 0 1px 3px rgba(53,35,21,.26);
    transition: background .16s ease, border-color .16s ease;
}
.cloth-index span {
    width: 16px;
    height: 3px;
    border-radius: 99px;
    background: repeating-linear-gradient(90deg, #5d261e 0 3px, #b9893c 3px 4px, #7c2d1f 4px 6px);
    box-shadow: 0 1px 0 rgba(246,232,198,.4);
}
.cloth-index:hover { background: rgba(240,227,194,.62); border-color: #7c2d1f; }
.cloth-index:focus-visible { outline: 3px dashed #f0e3c2; outline-offset: 4px; }

.atlas-field {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(4, 1fr);
    aspect-ratio: 7 / 4;
    overflow: hidden;
    background: #d1c09a;
}

.atlas-master {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.emblem,
.atlas-rest {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.emblem {
    position: absolute;
    left: var(--hit-left);
    top: var(--hit-top);
    width: var(--hit-width);
    height: var(--hit-height);
    z-index: 1;
    cursor: pointer;
    touch-action: manipulation;
}
.emblem:focus { outline: none; }
.emblem.is-selected,
.emblem.is-pressed { z-index: 6; }

.atlas-slice {
    position: absolute;
    inset: 0;
    display: block;
    background-image: url('tapestry-assets/overview-atlas-v4.webp');
    background-repeat: no-repeat;
    background-size: 700% 400%;
    background-position: var(--atlas-x) var(--atlas-y);
    opacity: 0;
    pointer-events: none;
}

.emblem-label {
    position: absolute;
    left: 50%; bottom: 6%;
    z-index: 4;
    --label-x: -50%;
    width: max-content;
    max-width: 160%;
    transform: translate(var(--label-x), 5px);
    padding: 5px 9px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: clamp(8px, .82vw, 12px);
    letter-spacing: .045em;
    color: #6f281e;
    background: rgba(240,227,194,.94);
    border: 1px dashed rgba(124,45,31,.78);
    box-shadow: inset 0 0 0 2px rgba(240,227,194,.8), 0 2px 5px rgba(45,31,18,.28);
    opacity: 0;
    transition: opacity .14s ease, transform .18s ease;
    pointer-events: none;
}
.emblem.is-selected .emblem-label,
.emblem.is-pressed .emblem-label {
    opacity: 1;
    transform: translate(var(--label-x), 0);
}
.emblem[data-col="0"] .emblem-label { left: 6%; --label-x: 0%; }
.emblem[data-col="6"] .emblem-label { left: auto; right: 6%; --label-x: 0%; }

@media (hover: hover) and (pointer: fine) {
    .emblem:hover { z-index: 6; }
    .emblem:hover .emblem-label {
        opacity: 1;
        transform: translate(var(--label-x), 0);
    }
}

.overview-about {
    margin-top: 24px;
    padding-top: 22px;
    border-top: 2px dashed rgba(124,45,31,.5);
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.5fr);
    gap: 24px 42px;
}
.overview-about p { font-size: 14px; line-height: 1.65; color: #4d3d29; }
.overview-about-links { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; }
.overview-about-links a { color: #7c2d1f; font-weight: 700; text-decoration: none; border-bottom: 1px dashed currentColor; }
.overview-career { display: grid; gap: 6px; }
.overview-career-row { display: grid; grid-template-columns: 128px 1fr auto; gap: 12px; padding-bottom: 5px; border-bottom: 1px dashed rgba(61,48,32,.25); font-size: 11px; }
.overview-career-row span:first-child { font-variant-numeric: tabular-nums; color: #5c4c35; }
.overview-career-row span:nth-child(2) { font-family: 'Cinzel', serif; font-weight: 700; }
.overview-career-row span:last-child { color: #7c2d1f; font-weight: 700; letter-spacing: .08em; }

@media (max-width: 720px) {
    body.overview-v2 { overflow: hidden; }
    #tapestry-overview {
        place-items: start center;
        padding: 8px;
    }
    .great-cloth {
        width: min(96vw, calc((100svh - 28px) * .517), 500px);
        margin: auto 0;
        border-width: 5px;
    }
    .cloth-index { width: 34px; right: 6px; }
    .atlas-field {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(7, 1fr);
        aspect-ratio: 4 / 7;
    }
    .atlas-master { display: none; }
    .emblem {
        position: relative;
        left: auto;
        top: auto;
        width: auto;
        height: auto;
    }
    .atlas-slice { opacity: 1; }
    .emblem-label,
    .emblem[data-col="0"] .emblem-label,
    .emblem[data-col="6"] .emblem-label {
        left: 50%; right: auto;
        --label-x: -50%;
        width: auto; max-width: 98%;
        padding: 4px 5px 3px;
        font-size: 8px;
    }
    .overview-about { grid-template-columns: 1fr; }
    .overview-career-row { grid-template-columns: 100px 1fr; }
    .overview-career-row span:last-child { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
    .atlas-slice,
    .emblem-label { transition: none !important; }
}
