/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    background-color: #ffffff;
    color: #000000;
    height: 100vh;
    overflow: hidden;
}

/* ================= INITIALIZATION MODAL ================= */
.init-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.init-modal {
    background-color: #fff;
    border: 2px solid #FF3300;
    padding: 30px;
    width: 450px;
    box-shadow: 10px 10px 0 rgba(0,0,0,0.1);
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
}

/* Directory, bovine registry, and CC whitepaper modals use Inter for body text */
#directory-overlay .init-modal,
#bovine-registry-overlay .init-modal,
#cc-overlay .init-modal {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Hide scrollbar in the CC whitepaper box while keeping scroll behaviour */
#cc-modal-inner {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
#cc-modal-inner::-webkit-scrollbar {
    display: none;
}

/* Headers inside those modals stay Courier */
#directory-overlay .init-header,
#bovine-registry-overlay .init-header,
#cc-overlay .init-header {
    font-family: 'Courier New', Courier, monospace;
}

.init-header {
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 15px;
    color: #FF3300;
    border-bottom: 1px dashed #000;
    padding-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.init-header span:first-child {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.init-header span:last-child {
    flex-shrink: 0;
    font-size: 12px;
    white-space: nowrap;
}

.init-modal p {
    margin-bottom: 25px;
    line-height: 1.5;
}

.init-input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-weight: bold;
}

.init-input-group label {
    width: 30%;
}

.init-input-group select {
    width: 65%;
    font-family: inherit;
    font-size: 12px;
    border: none;
    border-bottom: 1px dashed #000;
    padding: 5px 2px;
    background: transparent;
    outline: none;
    cursor: pointer;
}

/* Hide scrollbar on init modal columns */
#init-overlay .init-modal div::-webkit-scrollbar {
    display: none;
}

/* Adds a hover effect to the clickable metric in the header */
#steward-directory-btn:hover {
    color: #FF3300;
}

/* Grotesque sans-serif for interactive header labels */
#steward-directory-btn,
#bovine-registry-btn,
#cc-display {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 8.5px;
    font-weight: 500;
    letter-spacing: 0.03em;
}

/* Mobile-only links row — hidden on desktop */
#header-links {
    display: none;
}

/* Grid Architecture */
.dashboard-container {
    display: grid;
    height: 100vh;
    grid-template-rows: auto 1fr 120px;
    grid-template-columns: 55% 22.5% 22.5%;
}

/* Header Container */
.header {
    grid-column: 1 / -1;
    border-bottom: 1px solid #000;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    padding: 4px 12px;
    background: #fff;
    overflow: hidden;
    gap: 0 10px;
    height: 32px;
}

/* The CattleDAO Logo */
.brand {
    font-size: 16px;
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    letter-spacing: -0.5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    cursor: pointer;
}

.brand-hoof {
    height: 14px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    filter: brightness(0);
}

.sys-info {
    font-size: 8.5px;
    letter-spacing: 0.06em;
    color: #555;
    white-space: nowrap;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: clip;
}

.metrics {
    font-size: 8.5px;
    letter-spacing: 0.04em;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    direction: rtl;
    text-align: left;
}

.user-info {
    font-size: 8.5px;
    letter-spacing: 0.04em;
    color: #444;
    white-space: nowrap;
    flex-shrink: 0;
}

#message-board-btn {
    flex-shrink: 0;
    cursor: pointer;
    font-family: 'Inter','Helvetica Neue',Helvetica,Arial,sans-serif;
    font-size: 8.5px;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-decoration: underline;
    white-space: nowrap;
}

/* Medium screens — hide sys-info to free space */
@media (max-width: 1100px) and (min-width: 769px) {
    .sys-info {
        display: none;
    }
}

/* Small desktop — also hide user-info */
@media (max-width: 900px) and (min-width: 769px) {
    .sys-info {
        display: none;
    }
    .user-info {
        display: none;
    }
}

/* --- UPDATED MAP ARCHITECTURE --- */
.map-pane {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    border-right: 1px solid #000;
    position: relative;
    overflow: auto;
    background-color: #f0f0f0;
    cursor: grab;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.map-pane::-webkit-scrollbar {
    display: none;
}

.map-pane:active {
    cursor: grabbing;
}

#map-surface {
    position: relative;
    width: 2500px;
    height: 2415px;
    transform-origin: top left;
}

/* --- THE PROCEDURAL NODES --- */
.bovine-node {
    position: absolute;
    width: 20px;
    height: 22px;
    background: url('images/Hoof.svg') center / contain no-repeat;
    border: none;
    box-shadow: none;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 5;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.15s;
    contain: layout style;
}

.bovine-node:hover {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.7);
    z-index: 10;
    filter: brightness(0);
}

@keyframes ring-expand {
    0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.85; }
    100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0;    }
}

.bovine-node.is-mempool {
    z-index: 6;
}

.bovine-node.is-mempool::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid #FF3300;
    background: transparent;
    transform: translate(-50%, -50%) scale(0.6);
    animation: ring-expand 1.4s ease-out infinite;
    pointer-events: none;
}

.bovine-node.is-mempool:hover::before {
    animation: none;
    opacity: 0;
}

.bovine-node.is-mempool:hover {
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.7);
    z-index: 10;
}

.bv-flag {
    position: absolute;
    top: -8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 1px;
    color: #000000;
    font-family: monospace;
    font-size: 7px;
    font-weight: bold;
    letter-spacing: 0.03em;
    line-height: 1;
    padding: 1px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    transform: rotate(calc(-1 * var(--rot, 0deg)));
    transform-origin: left center;
}

.bv-flag::before {
    content: '+';
    font-size: 9px;
    line-height: 1;
    margin-right: 1px;
}

/* --- GAUSHALA POLE NODE --- */
.gaushala-node {
    position: absolute;
    width: 26px;
    height: 22px;
    background-color: #FF977F;
    border: none;
    clip-path: polygon(50% 0%, 100% 45%, 85% 45%, 85% 100%, 15% 100%, 15% 45%, 0% 45%);
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 8;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gaushala-node:hover {
    transform: translate(-50%, -50%) scale(1.5);
    background-color: #cc5c3c;
    z-index: 12;
}

/* Ledger & Mempool */
.ledger-pane {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
}

.mempool-pane {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    border-right: 1px solid #000;
}

.panel-scroll {
    overflow-y: auto;
    padding: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.panel-scroll::-webkit-scrollbar {
    display: none;
}

.block-entry, .mempool-entry {
    margin-bottom: 20px;
    line-height: 1.4;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 10px;
}

.action-text {
    color: #FF3300;
    font-weight: bold;
    cursor: pointer;
}

/* Buttons Pane */
.buttons-pane {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    border-top: 1px solid #000;
    border-right: 1px solid #000;
    display: flex;
    gap: 20px;
    padding: 20px;
    position: relative;
}

.btn {
    flex: 0 0 calc(50% - 10px);
    background-color: #FF3300;
    color: #000;
    border: none;
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #cc2900;
}

.btn-submit {
    width: 100%;
    padding: 10px 0;
    margin-top: 10px;
    background-color: #000;
    color: #FF3300;
    border: 1px solid #FF3300;
}

.btn-submit:hover {
    background-color: #FF3300;
    color: #000;
}

/* The Propose Care Form pop-up */
.propose-form {
    display: none;
    position: absolute;
    top: 20px;
    left: 20px;
    transform: translateY(-100%);
    width: 400px;
    background: #fff;
    border: 2px solid #FF3300;
    padding: 20px;
    z-index: 10;
    box-shadow: 5px 5px 0 rgba(0,0,0,0.1);
    overflow: visible;
}

.propose-form.active {
    display: block;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-weight: bold;
}

.form-row label {
    width: 35%;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
}

.form-row select, .form-row input {
    width: 60%;
    font-family: inherit;
    font-size: 11px;
    border: none;
    border-bottom: 1px dashed #000;
    padding: 2px;
    background: transparent;
    outline: none;
}

/* ── Tooltip question marks on propose form ── */
.form-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #999;
    font-size: 9px;
    font-weight: 700;
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #999;
    cursor: help;
    position: relative;
    vertical-align: middle;
    margin-left: 4px;
    line-height: 1;
    flex-shrink: 0;
}

.form-tooltip:hover {
    border-color: #FF3300;
    color: #FF3300;
}

.form-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    transform: none;
    width: 260px;
    padding: 10px 12px;
    background: #000;
    color: #fff;
    font-size: 10px;
    font-weight: 400;
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.55;
    letter-spacing: 0.02em;
    white-space: pre-line;
    border-radius: 2px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 200;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.form-tooltip::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 12px;
    transform: none;
    border: 5px solid transparent;
    border-bottom-color: #000;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 201;
}

.form-tooltip:hover::after,
.form-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Terminal */
.terminal-pane {
    grid-column: 2 / 4;
    grid-row: 3 / 4;
    border-top: 1px solid #000;
    background-color: #fff;
}

/* ================= DOSSIER CARD ================= */
.dossier-card {
    display: none;
    position: absolute;
    width: 360px;
    overflow-y: visible;
    background-color: #ffffff;
    border: 1px solid #000;
    padding: 15px;
    z-index: 100;
    box-shadow: 5px 5px 0 rgba(0,0,0,0.1);
    pointer-events: all;
}

.dossier-card::-webkit-scrollbar {
    display: none;
}

.dossier-card.active {
    display: block;
}

.dossier-rule {
    border: none;
    border-top: 1px dashed #000;
    margin: 8px 0;
    width: 100%;
}

.dossier-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 15px;
}

.dossier-close {
    cursor: pointer;
    color: #FF3300;
}

.dossier-close:hover {
    color: #000;
}

.dossier-image {
    width: 100%;
    height: auto;
    border: 1px solid #000;
    margin-bottom: 15px;
    filter: contrast(1.2) grayscale(0.2);
}

/* --- THE LIVE ANIMATION --- */
@keyframes terminalPulse {
    0% { color: #FF3300; opacity: 1; }
    50% { color: #000000; opacity: 0.6; }
    100% { color: #FF3300; opacity: 1; }
}

.live-alert {
    display: inline-block;
    animation: terminalPulse 1.5s infinite steps(2, end);
    font-weight: bold;
}

/* ══ COMMUNITY MESSAGE BOARD ══ */
#message-board-modal {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
#message-board-modal .init-header {
    font-family: 'Courier New', Courier, monospace;
}
#board-thread::-webkit-scrollbar {
    display: none;
}
.board-message {
    border: 1px solid #e8e8e8;
    border-radius: 2px;
    padding: 10px 12px;
    background: #fafafa;
    font-size: 12px;
    line-height: 1.6;
}
.board-message .board-meta {
    font-size: 10px;
    color: #999;
    margin-bottom: 5px;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.03em;
}
.board-message .board-author {
    color: #555;
    font-weight: 600;
}
.board-message .board-body {
    color: #222;
}
.board-empty {
    text-align: center;
    color: #bbb;
    font-size: 11px;
    padding: 24px 0;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════
   MOBILE LAYOUT  ≤ 768px
══════════════════════════════════════════ */
@media (max-width: 768px) {

    body {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }

    .dashboard-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .header {
        flex-shrink: 0;
        height: auto;
        padding: 5px 10px;
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        overflow: hidden;
        row-gap: 1px;
    }

    .brand {
        font-size: 16px;
        flex: 1 1 100%;
        order: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        gap: 5px;
    }

    .brand-hoof {
        height: 14px;
    }

    .sys-info  { display: none; }
    .metrics   { display: none; }
    .user-info { display: none; }

    #message-board-btn {
        display: none;
    }

    #header-links {
        display: block;
        width: 100%;
        order: 2;
        font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
        font-size: 9px;
        font-weight: 500;
        letter-spacing: 0.03em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.6;
    }

    .map-pane {
        grid-column: unset;
        grid-row: unset;
        width: 100%;
        flex: 1 1 0;
        min-height: 0;
        border-right: none;
        border-bottom: 1px solid #000;
        cursor: grab;
    }

    .buttons-pane {
        grid-column: unset;
        grid-row: unset;
        flex-direction: column;
        gap: 0;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        border-right: none;
        border-top: none;
        flex-shrink: 0;
    }

    #btn-propose {
        width: 100%;
        padding: 18px 0;
        font-size: 13px;
        flex: none;
        border-radius: 0;
        border-top: 1px solid #000;
        border-bottom: 1px solid #000;
    }

    .propose-form {
        position: static;
        top: auto;
        left: auto;
        bottom: auto;
        transform: none;
        width: 100%;
        border-left: none;
        border-right: none;
        border-top: none;
        box-shadow: none;
        padding: 12px 14px;
    }

    .form-tooltip::after {
        top: calc(100% + 8px);
        bottom: auto;
        left: 0;
        transform: none;
        width: 220px;
    }
    .form-tooltip::before {
        top: calc(100% + 2px);
        bottom: auto;
        left: 12px;
        transform: none;
        border-top-color: transparent;
        border-bottom-color: #000;
    }

    .mempool-pane {
        grid-column: unset;
        grid-row: unset;
        height: 200px;
        flex-shrink: 0;
        border-top: 1px solid #000;
        border-bottom: 1px solid #000;
    }

    .ledger-pane {
        grid-column: unset;
        grid-row: unset;
        height: 130px;
        flex-shrink: 0;
        border-right: none;
        border-top: 1px solid #000;
        border-bottom: none;
    }

    .terminal-pane {
        display: none;
    }

    .mempool-pane::before {
        content: 'MEMPOOL // PENDING OBLIGATIONS';
        display: block;
        font-size: 9px;
        letter-spacing: 0.08em;
        color: #aaa;
        padding-bottom: 6px;
        border-bottom: 1px dotted #ddd;
        margin-bottom: 8px;
    }

    .ledger-pane::before {
        content: 'LEDGER // CONFIRMED BLOCKS';
        display: block;
        font-size: 9px;
        letter-spacing: 0.08em;
        color: #aaa;
        padding-bottom: 6px;
        border-bottom: 1px dotted #ddd;
        margin-bottom: 8px;
    }

    .dossier-card {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 75vh;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-width: none;
        -ms-overflow-style: none;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
        border-top: 2px solid #000;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 12px 14px;
        z-index: 200;
    }

    .dossier-card::-webkit-scrollbar { display: none; }

    .dossier-header {
        font-size: 11px;
        margin-bottom: 10px;
    }

    .dossier-image {
        max-height: none;
        width: 100%;
        object-fit: cover;
        margin-bottom: 8px;
    }

    .dossier-data {
        font-size: 10px;
        line-height: 1.5;
    }

    .init-overlay {
        align-items: flex-end;
    }

    .init-modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        overflow-y: auto;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -6px 24px rgba(0,0,0,0.15);
        padding: 20px 16px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .init-modal::-webkit-scrollbar { display: none; }

    #init-overlay {
        align-items: flex-start;
        padding-top: 12px;
    }

    #init-overlay .init-modal {
        border: 2px solid #FF3300;
        margin: 0 16px;
        width: calc(100% - 32px) !important;
        max-height: 88vh !important;
        max-height: 88dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        flex-direction: column !important;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #init-overlay .init-modal div::-webkit-scrollbar {
        display: none;
    }

    #init-overlay .init-modal > div:last-child {
        flex-direction: column !important;
        flex: none !important;
        min-height: auto !important;
        overflow: visible !important;
    }

    #init-overlay .init-modal > div:last-child > div {
        flex: none !important;
        border-right: none !important;
        border-bottom: 1px solid #000;
        max-height: none !important;
        overflow-y: visible !important;
    }
}