:root {
    --border: var(--border);
}

/* Responsive font size using clamp */
html { 
    font-size: clamp(16px, 1.5vw, 21px); 
}

/* English: ltr-ncnd-variable first, fallback to Sandoll Typewrite for other characters (Korean, etc.) */
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "ltr-ncnd-variable", "Sandoll Typewrite", sans-serif;
    font-style: normal;
    font-weight: 300;
    font-variation-settings: "wght" 500; /* for ltr-ncnd-variable */
    background-image: url("../background.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Links: blue, underline, 4px offset */
a {
    color: blue;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Korean characters wrapped in span - font size 75% and weight 300 */
span[style*="font-size: 0.75em"],
span[style*="font-weight: 300"] {
    font-size: 0.75em !important;
    font-weight: 300 !important;
}

/* SVG container: full screen size, clip content so lines don't overflow */
#network-graph {
    width: 100vw;  /* 100% of viewport width */
    height: 100vh;  /* 100% of viewport height */
    overflow: hidden;
}

/* Node (logo) and path: clickable indicator → pointer cursor */
.node {
    cursor: pointer;
}

/* Logo wrapper: scale only from group center (image center) on hover, no position movement */
.node .logo-wrap {
    transform-origin: 0 0; /* group local (0,0) = node center = image center */
    transition: transform 0.2s ease;
}
.node:hover .logo-wrap {
    transform: scale(1.1);
}
/* Node logo image: bubble click/drag events to parent, pointer cursor */
.node .logo-wrap image {
    pointer-events: auto;
    cursor: pointer;
}

/* Node text background: white box behind text */
.node .text-bg {
    fill: white;
    pointer-events: none;
}
/* Node text: English first, fallback to Sandoll Typewrite (inherits rem from html) */
.node text {
    font-family: "ltr-ncnd-variable", "Sandoll Typewrite", sans-serif;
    fill: #333;
    pointer-events: none;
    font-size: 0.75rem;
    font-weight: 600;
    font-variation-settings: "wght" 600; /* for ltr-ncnd-variable */
}

/* Korean characters in node text - smaller size */
.node text tspan {
    font-size: 0.6em;
    font-weight: 300;
}

/* Link (connection line): wobbly clay brush effect */
.link {
    stroke: #fff;
    stroke-width: 5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    cursor: pointer;
    filter: url(#clay-stroke);
}
/* Map device icons: draggable; rect is hit area, image does not capture pointer */
.device {
    cursor: grab;
    pointer-events: auto;
}
.device:active {
    cursor: grabbing;
}
.device image {
    pointer-events: none;
}
.device rect {
    cursor: inherit;
}
/* 아이콘 밑 이름 (object-oriented-mapping처럼) */
.device .device-label-bg {
    fill: white;
    pointer-events: none;
}
.device .device-label {
    font-family: "ltr-ncnd-variable", "Sandoll Typewrite", sans-serif;
    fill: #333;
    pointer-events: none;
    font-size: 0.75rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
}

/* Device modal (object-oriented-mapping style): open on icon click */
.device-modal {
    position: fixed;
    inset: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.2s, opacity 0.2s;
}
.device-modal.show {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
}
.device-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
.device-modal-content {
    position: relative;
    max-width: 28rem;
    max-height: 85vh;
    overflow-y: auto;
    background: white;
    border: 1px solid #333;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.device-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.device-modal-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
}
.device-modal-close {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid #333;
    background: white;
    font-size: 1.25rem;
    cursor: pointer;
    font-family: inherit;
}
.device-modal-close:hover {
    background: #333;
    color: white;
}
.device-modal-body {
    margin: 0;
    font-size: 0.9375rem;
    color: #333;
}

/* About link + panel (object-oriented-mapping style) */
.about-link {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.about-link button {
    color: #333;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.35em 0.65em;
    border: 1px solid #333;
    background: white;
    cursor: pointer;
    font-family: inherit;
}
.about-link button:hover {
    background: #333;
    color: white;
}

.about-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1002;
    display: none;
    max-height: 100vh;
    overflow-y: auto;
    padding: 1rem;
    width: 28rem;
    max-width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.97);
    border-left: 1px solid #333;
}
.about-panel.is-open {
    display: block;
}
.about-panel-content {
    position: relative;
    width: 100%;
}
.about-panel-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin: 0 0 1rem 0;
    padding: 0;
    align-items: center;
}
.about-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    font-variation-settings: "wght" 600;
}
.about-panel-header button {
    background: none;
    border: none;
    padding: 0.25em;
    margin: 0;
    cursor: pointer;
    color: #333;
    font-size: 1.75rem;
}
.about-panel-header button:hover {
    color: #000;
}
.about-panel-text {
    font-size: 0.9375rem;
    color: #333;
}
.about-panel-text p {
    margin: 0 0 1em 0;
}
.about-panel-text p:last-child {
    margin-bottom: 0;
}

/* 한/영: 기본 한글, .lang-en 이면 영어 블록만 표시 */
.about-panel-text__en {
    display: none;
}
.about-panel.lang-en .about-panel-text__ko {
    display: none;
}
.about-panel.lang-en .about-panel-text__en {
    display: block;
}

#about-lang-toggle {
    font-size: 0.875rem;
    padding: 0.35em 0.65em;
}

@media (max-width: 768px) {
    .about-panel {
        width: 100%;
        border: none;
    }
}

.device-modal-tags {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
}
.device-modal-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.2em 0.5em;
    font-size: inherit;
    color: #333;
    background: transparent;
    border: 1px solid #333;
    border-radius: 2px;
}
.device-modal-tag-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Tooltip box next to mouse: text-size based (replaces speech bubble) */
.tooltip {
    position: absolute;
    background: white;
    color: #333;
    border: 1px solid #333;
    pointer-events: none;
    z-index: 1000;
    overflow: visible;
    display: none;
}
.tooltip .tooltip-text {
    display: block;
    padding: 6px 10px;
}
.tooltip.show {
    display: block;
}
.tooltip.clickable {
    pointer-events: auto;
    cursor: pointer;
    text-decoration: underline;
}

.about-link {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1002;
}

.about-link button {
    color: black;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border: var(--border);
    background: white;
    cursor: pointer;
    font-family: inherit;
}

.about-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.about-link button:hover {
    background: black;
    color: white;
}
.about-link #about-lang-toggle {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
}

.about-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1002;
    display: none;
    max-height: 100vh;
    overflow-y: auto;
    padding: 1rem;
    width: 25rem;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    border-left: var(--border);
}

@media (max-width: 768px) {
    .about-panel {
        width: 100%;
        border: none;
    }
}

.about-panel.is-open { 
    display: block; 
}

.about-panel-content {
    position: relative;
    width: 100%;
}

.about-panel-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin: 0 0 1rem 0;
    padding: 0;
    align-items: center;
}

.about-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: normal;
}

.about-panel-header button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: #333;
    font-size: 2rem;
}

.about-panel-text {
}
.about-panel-text__en {
    display: none;
}
.about-panel.lang-en .about-panel-text__ko {
    display: none;
}
.about-panel.lang-en .about-panel-text__en {
    display: block;
}
.about-panel-text p {
    margin-bottom: 1.5rem;
}
.about-panel-text p:last-child {
    margin-bottom: 0;
}

.articles-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    display: none;
    width: min(25rem, 90vw);
    max-width: 28rem;
    max-height: 80vh;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.95);
    box-sizing: border-box;
    border: var(--border);
}
@media (max-width: 768px) {
    .articles-panel {
        width: min(22rem, 92vw);
        max-height: 85vh;
    }
}
@media (min-width: 1280px) {
    .articles-panel {
        width: 26rem;
    }
}
.articles-panel.is-open { display: block; }
.articles-panel-content {
    position: relative;
    width: 100%;
}
.articles-panel-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 0 0 1rem 0;
    padding: 0;
}
.articles-panel-header button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: #333;
    display: flex;
    justify-content: flex-end;
    font-size: 2rem;
}
.articles-panel-title-block {
    flex: 1;
    min-width: 0;
}
#articles-panel-title {
    margin: 0;
    padding: 0;
}
#articles-panel-title a {
    display: inline;
}
.articles-panel-links {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.articles-panel-btn {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid currentColor;
    border-radius: 2px;
    text-decoration: none;
    color: blue;
}
.articles-panel-btn:hover {
    background: black;
    color: white;
}
.articles-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.articles-panel li {
    background: white;
    /* padding: 0.5rem; */
    margin-bottom: 0.5rem;
}
.articles-panel li:last-child {
    margin-bottom: 0;
}

/* Cover entire screen before font load + show 1%~100% loading */
.font-loading {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "ltr-ncnd-variable", "Sandoll Typewrite", sans-serif;
    color: #333;
}
.font-loading.done {
    pointer-events: none;
}
.font-loading-pct { font-variant-numeric: tabular-nums; }

/* Footprint animation */
.footprint {
    position: fixed;
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 1;
}
.footprint img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Project footer: version + update policy */
.project-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    pointer-events: none;
}
.project-footer__version {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.project-footer__copyright {
    opacity: 0.85;
}
