:root {
    --accent-cream: #fdfbea;
    --accent-orange: #ec5109;
    --accent-light-orange: #f38c55;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #737373;
    --border-light: #e5e5e5;
    --border-medium: #d4d4d4;
    --surface-white: #ffffff;
    --surface-warm: #fffdf5;
    --surface-gray: #f6f6f6;
}

.is-hidden { display: none !important; }
.is-active { color: var(--accent-orange); font-weight: 600; }
.is-missing { color: var(--text-muted); font-style: italic; }

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
    /* background-color: var(--surface-warm); */
    background-color: var(--surface-warm);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hero-section {
    position: relative;
    height: 120px;
    margin-bottom: 10px;
    /* background-image: url("/assets/images/mwdwg.jpg"); */
    overflow:hidden;
}

.hero-section p {
    line-height: 1.1;
    margin: 0.5rem auto;
}
  
.hero-section img {
    -webkit-user-drag: none; 
    position: absolute;
    width: 100%;
    height: 150px;
    object-fit: cover;
    z-index: 0;
    filter: opacity(20%);
    overflow: hidden;
    
    mask-image: linear-gradient(
    to bottom,
    /* -45deg, */
    transparent 0%,
    /* black 0%, */
    black 15%,
    transparent 80%
    );
}

.hero-section > div {
    position: relative;
    z-index: 1;
}

.hero-desktop {
    display: block;
    color: var(--accent-orange);
}

.hero-mobile {
    display: none;
    color: var(--accent-orange);
}

.result-wrapper {
    overflow-x: auto;
}

.result-wrapper:a {
    text-decoration: none;
}
.result-wrapper:a:hover {
    text-decoration: underline;
}

.site-footer {
    padding: 1rem 1rem;
    border-top: 1px solid var(--border-light);
    background-color: var(--accent-cream);
    color: var(--text-secondary);
    text-align: center;
}

.site-header {
    color:var(--text-primary);
    background-color: var(--accent-cream);
    /* border-bottom: 1px solid var(--border-light); */
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.site-header-container {
    font-size: 1rem;
    margin: 0 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* makes the logo and buttons distribute on two ends */
}

.site-logo {
    display: inline-flex;
    padding: 0.375rem 0.875rem;
    min-width: 240px;

    border-radius: 0.25rem;
    border: 1px solid var(--accent-light-orange);
    background: var(--accent-light-orange);
    color: var(--accent-cream);

    /* font-size: 0.8125rem; */
    letter-spacing: 0.02em;

    text-decoration: none;

    transition: background 0.15s;
    cursor: default;
}

.site-logo:hover {
    background-color: var(--accent-cream);
    color: var(--accent-orange);
}

.site-navbar {
    /* TODO: TO BE IMPLEMENTED */
}

.nav-item {
    display: inline-flex;
    padding: 0.375rem 0.875rem;
    border-radius: 0.25rem;
    /* color: var(--text-secondary); */
    text-decoration: none;
    transition: background 0.15s;
    cursor: default;
}

.nav-item {
    color: var(--text-primary);
}

.nav-item:hover {
    background: var(--accent-light-orange);
    color: var(--accent-cream);
}

.nav-item.is-active {
    color: var(--accent-orange);
}

.nav-item.is-active:hover {
    color: var(--surface-warm);
}

/* TBD: breadcrumb */

.page-home {
    position:relative;
    margin: 0 0.75rem 1rem 0.75rem;
    padding: 0 0.75rem;
    gap: 1rem;
    flex: 1 0 auto; /* 拉伸填满剩余空间，但允许增长 */
}

@media screen{
    .page-record {
        margin: 0 0.75rem;
        /*min-width: 0; */
        padding: 1rem 0.75rem;
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: 1rem;
        flex: 1 0 auto; /* 拉伸填满剩余空间，但允许增长 */
    }
}

.loader-wrapper {
    display: flex;
    align-items: center;      /* 垂直居中 */
    justify-content: center;  /* 水平居中 —— 新增 */
    overflow-x: auto;
    min-height: 50vh;         /* 给容器足够高度，让垂直居中明显 */
}

.anim-loader {
    margin: 10px;
    border: 16px solid #f3f3f3;
    border-radius: 50%;
    border-right: 16px solid var(--accent-light-orange);
    width: 120px;
    height: 120px;
    -webkit-animation: spin 0.75s linear infinite; /* Safari */
    animation: spin 0.75s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  }
  
  /* Safari */
  @-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); }
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

/* aside meta and tool box */

.meta-panel {
    font-size: 0.825rem;
}

.meta-section {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    padding: 1rem 0.875rem;
    margin-bottom: 1rem;
}

.meta-heading {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.875rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.375rem 0;
    border-bottom: 1px dotted var(--border-light);
}

.meta-row:last-child {
    border-bottom: none;
}

.meta-label {
    color: var(--text-muted);
    font-weight: 400;
}

.meta-value {
    color: var(--text-primary);
    text-align: right;
    align-self: right;
    /* max-width: 70%;  */
}

.meta-value.is-missing {
    color: var(--text-muted);
    font-style: italic;
}

.meta-value .circa {
    color: var(--text-muted);
}

/* main record box */

.record-body {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    padding: 2rem 2.5rem;
    overflow-x: auto;
}

.record-title-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.record-title {
    font-size: 1.75rem;
    font-weight: 400;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.record-title.english {
    color: var(--text-primary);
}

.record-title.nina {
    font-size: 1.125rem;
    font-style: italic;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.record-citation {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.record-action-block {
    border-bottom: 1px solid var(--border-light);
}

.record-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 0.125rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    cursor:default;
}

.tag-item.is-primary {
    border-color: var(--accent-orange);
    color: var(--accent-orange);
    background: transparent;
}

.content-section {
    margin-bottom: 2rem;
}

.content-section:last-child {
    margin-bottom: 0;
}

.section-heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    /* border-bottom: 2px solid var(--accent-orange); */
    display: inline-block;
}

.section-heading.tight {
    margin-bottom: 0;
}

.agent-table {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.agent-table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
    background: var(--surface-warm);
}

.agent-table td {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}

/* .agent-table tr:last-child td {
    border-bottom: none;
} */

.agent-name {
    font-weight: 500;
    color: var(--text-primary);
}

.agent-name.note {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem;
}

.agent-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    /* text-transform: uppercase; */
    letter-spacing: 0.04em;
}

.agent-note {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    /* line-height: 1.4; */
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-light);
    border-radius: 0.125rem;
    font-size: 0.8125rem;
}

.feature-status {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    flex-shrink: 0;
}

.feature-status.is-yes {
    background: var(--accent-light-orange);
    color: var(--accent-cream);
}

.feature-status.is-no {
    background: var(--border-light);
    color: var(--text-muted);
}

.feature-label {
    color: var(--text-muted);
}

.feature-label.is-active {
    color: var(--text-primary);
    font-weight: 500;
}

.tool-panel {
    font-size: 0.8125rem;
}

.tool-section {
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.tool-heading {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 1rem;
}

.tool-link {
    display: block;
    padding: 0.325rem 0;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-light);
    transition: color 0.15s;
}

.tool-link:last-child {
    border-bottom: none;
}

.tool-link:hover {
    color: var(--accent-orange);
}

.tool-link .link-title {
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.link-rationale {
    color: var(--accent-light-orange);
}

.link-rationale:hover {
    color: var(--accent-orange);
}

.sendto-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sendto-btn {
    flex: 1 1 0;           /* 等宽：flex-grow, flex-shrink, flex-basis */
    min-width: 90px;       /* 最小宽度 - 防止过度压缩？需要一个更好的解决方法 */
    padding: 0.5rem 0.25rem;
    border: 1px solid var(--border-medium);
    background: var(--surface-white);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    transition: all 0.15s;
    text-align: center;
}

.sendto-btn.is-disabled { color: var(--text-secondary); background-color: var(--border-medium); }


/* 悬停状态 */
.sendto-btn:hover {
    background: var(--accent-light-orange);
    color: var(--surface-white);
}

/* 引用块 */
.citation-box {
    background: var(--surface-warm);
    /* border-left: 3px solid var(--accent-orange); */
    padding: 1rem 1.25rem;
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.citation-box a {
    color: var(--accent-orange);
    text-decoration: none;
}

.citation-box a:hover {
    text-decoration: underline;
}

.access-indicator {
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid var(--border-light); 
    border-radius: 0.25rem; 
    background-color: var(--surface-warm);
    transition: all 0.15s;
    text-align: center;
}
.access-indicator.public {
    background-color: #fdfbea;
}
.access-indicator.internal {
    background-color: var(--accent-light-orange);
}
.access-indicator:hover{
    background-color: var(--accent-orange);
    color: var(--surface-white);
}

/* universal panel classes */

.panel-overlay {
    position: fixed;           /* 相对于视口固定，不随滚动移动 */
    top: 0;
    left: 0;
    width: 100vw;              /* 铺满整个视口宽度 */
    height: 100vh;             /* 铺满整个视口高度 */
    z-index: 40;               /* 比 header (z-50) 低，比内容高 */
}

.panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.35);  /* 35% 黑色透明度 */
    backdrop-filter: blur(6px);              /* 毛玻璃模糊 */
    -webkit-backdrop-filter: blur(4px);      /* Safari 兼容 */
}

.panel-section {
    max-height: 70vh;         /* for mobile */
    overflow-y: auto; 
    position: relative;        /* 相对于 overlay 定位 */
    z-index: 2;                /* 在 backdrop 之上 */
    max-width: 50vw; 
    margin: 10vh auto;  
    background: var(--surface-white);
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    box-sizing: border-box; 
}

.panel-heading {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.875rem;
}

.panel-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.375rem 0;
    border-bottom: 1px dotted var(--border-light);
}

.panel-row:last-child {
    border-bottom: none;
}

.panel-btn-close {
    display: block;
    width: 100%;
    padding: 0.625rem;
    margin-top: 1rem;
    border: 1px solid var(--border-medium);
    border-radius: 0.25rem;
    background: var(--surface-warm);
    color: var(--text-secondary);
    font-family: inherit;      /* 继承 Cambria 字体 */
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s;
}

.panel-btn-close:hover {
    background: var(--accent-light-orange);
    color: var(--accent-cream);
    border-color: var(--accent-light-orange);
}


.panel-dropdown {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    background: var(--surface-gray);
    min-width: 100px;
    text-align: right;
}

.panel-input {
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 0.25rem;
    background: var(--surface-gray);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    overflow-x: auto;
    white-space: nowrap;
}

#permalinkUrl {
    width: 100%;
  }

/* TODO: populate with more selectors */

@media (max-width: 1024px) {
    .panel-section {
        max-width: 70vw;
    }
}


@media (max-width: 768px) {
    .record-body {
        padding: 1.5rem;
    }
    .hero-desktop {
        display: none;
    }
    .hero-mobile {
        display: block;
    }
    .feature-list {
        grid-template-columns: 1fr;
    }
    .panel-section {
        max-width: 90vw;
    }

    .site-navbar {
        display: none;
    }
    /* .hero-greeting {
        display: none; 
    } */

    /* Mobile vertical layout */
    .page-record {
        display: flex !important;
        flex-direction: column;
    }
    
    /* record-body visually first */
    .record-body {
        order: 1;
    }
    
    /* meta-panel visually last */
    .meta-panel {
        order: 2;
    }
}