/* Import All Global CSS Variables*/
@import "/v1/styles/shared_variables.css";
@import "/v1/styles/menu_close_arrow.css";

/* Override shared body-padding for the outer page layout */
:root {
    --body-padding: 1rem;
}

/* Remove all padding and margins */
* {
    margin: 0;
    padding: 0;
}

html {
    /* height: calc(100% - var(--body-padding) * 2); */
    /* margin: var(--body-padding); */
    height: 100%;
}

body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-size: var(--standard-font-size);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-evenly;
    flex-wrap: nowrap;
}

/* Dialog Messages */

section#messaging {
    display: none;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.4);
    z-index: 999;
}

section#messaging > dialog { 
    display: block;
    position: fixed;
    top: calc(50% + var(--header-height));
    left: 50%;
    max-width: 50vw;
    max-height: 50vh;
    margin-right: -45%;
    transform: translate(-50%, -50%);
    /* padding: var(--article-interface-font-size); */
    box-shadow: 0 4px 8px 0 var(--highly-transparent-dark);
    border-radius: var(--header-border-radius);
    background-color: var(--standard-background-color);
    border: none;
    overflow: hidden;
    z-index: 1000;
}

section#messaging > dialog > h1 {
    padding-top: var(--dialog-content-padding);
    padding-left: var(--dialog-content-padding);
    padding-right: var(--dialog-content-padding);
    background-color: var(--primary-color);
}

section#messaging > dialog > p {
    margin-top: var(--dialog-content-padding);
    padding-left: var(--dialog-content-padding);
    padding-right: var(--dialog-content-padding);
}

section#messaging nav.dialog-controls {
    display: grid;
    grid-template-columns: [download] auto [close] auto;
    margin-top: var(--dialog-content-padding);
    padding-left: var(--dialog-content-padding);
    padding-right: var(--dialog-content-padding);
    padding-bottom: var(--dialog-content-padding);
}

section#messaging a.close-dialog {
    grid-area: close;
    justify-self: end;
}

section#messaging a.download-citation {
    grid-area: download;
    justify-self: start;
}

section#messaging a.close-dialog,
section#messaging a.download-citation {
    background: var(--secondary-color);
    color: var(--standard-color);
    border-radius: var(--header-border-radius);
    line-height: calc(var(--standard-font-size) * 1.5);
    min-height: calc(var(--standard-font-size) * 1.5);
    font-size: var(--standard-font-size);
    text-decoration: none;
    min-width: calc(var(--standard-font-size) * 3);
    padding:0 0.5rem;
    box-shadow: 0 3px 6px 0 var(--highly-transparent-dark);
    transition: box-shadow 200ms, transform 200ms;
}

section#messaging a.close-dialog:focus,
section#messaging a.download-citation:focus {
    outline:0;
}

section#messaging a.close-dialog:hover,
section#messaging a.download-citation:hover {
    box-shadow: 0 6px 12px 0 var(--highly-transparent-dark);
    transform: translate(-1px, -1px);
    transition: box-shadow 50ms, transform 50ms;
}

section#messaging a.close-dialog:active,
section#messaging a.download-citation:active {
    box-shadow: 0 3px 6px 0 var(--highly-transparent-dark);
    transform: translate(0px, 0px);
    transition: box-shadow 200ms, transform 200ms;
}

qd-error-report { 
    box-shadow: 0 4px 8px 0 var(--highly-transparent-dark);
    border-radius: var(--header-border-radius);
    background-color: var(--standard-background-color);
    border: none;
    overflow: hidden;
    z-index: 2000;
}

/* Header */

header.qd-header {
    display: grid;
    grid-template-areas: "hamburger logo badges nav logos";
    grid-template-columns: auto auto auto 1fr auto;
    align-items: center;
    padding: 0 var(--body-padding);
    background-color: var(--primary-color);
    transition: margin-top 200ms;
    border-bottom: var(--handle-size) solid var(--tertiary-color);
    position: relative;
}

#project-logo {
    grid-area: logo;
}

#project-title {
    --title-font-size: calc(var(--standard-font-size) * 2);
    display: block;
    white-space: nowrap;
    font-size: var(--title-font-size);
    text-decoration: none;
    color: inherit;
}

#project-subtitle {
    display: block;
    font-size: var(--standard-font-size);
    margin-top: calc(var(--standard-font-size) * -0.7);
    margin-left: calc(var(--standard-font-size) * 2.4);
    text-decoration: none;
    color: inherit;
}

#badge-column {
    grid-area: badges;
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-self: start;
    padding-top: calc(var(--standard-font-size) * 0.3);
    margin-left: calc(var(--standard-font-size) * 0.5);
}

.qd-header-badge {
    display: block;
    font-size: calc(var(--standard-font-size) / 1.5);
    line-height: 1;
    padding: calc(var(--standard-font-size) / 6) calc(var(--standard-font-size) / 3);
    cursor: pointer;
    text-align: center;
}

#recent-articles-badge {
    --badge-tint: var(--toggle-on-color);
}

section#messaging > dialog#recent-articles-dialog {
    display: flex;
    flex-direction: column;
    max-width: 40rem;
    max-height: 60vh;
    overflow: hidden;
}

.recent-articles-filter {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem var(--dialog-content-padding);
}

.recent-articles-filter > .filter-btn {
    border: 1px solid var(--dividing-line-color);
    background: transparent;
    border-radius: var(--border-radius-small);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-family: var(--interface-font);
    font-size: var(--small-details-font-size);
}

.recent-articles-filter > .filter-btn.active {
    background-color: var(--badge-color);
    color: var(--warning-font-color);
    border-color: var(--badge-color);
}

.recent-articles-list {
    list-style: none;
    padding: 0 var(--dialog-content-padding);
    overflow: auto;
    margin: 0;
    flex: 1;
    min-height: 0;
}

.recent-articles-list > li {
    border-bottom: 1px solid var(--dividing-line-color);
}

.recent-article-link {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0;
    cursor: pointer;
    text-decoration: none;
    color: var(--standard-text-color);
}

.recent-article-link:hover {
    background-color: var(--primary-color);
}

.recent-article-meaning {
    flex: 1;
}

.recent-article-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: var(--small-details-font-size);
    color: var(--subdued-text-color);
}

.recent-article-status {
    padding: 0.1rem 0.4rem;
    font-size: 0.75em;
}

.recent-article-status.status-new {
    --badge-tint: var(--toggle-on-color);
    background-color: color-mix(in srgb, var(--badge-tint) 14%, white);
}

.recent-article-status.status-updated {
    --badge-tint: var(--badge-color);
    background-color: color-mix(in srgb, var(--badge-tint) 14%, white);
}

dialog#changelog {
    flex-direction: column;
}

dialog#changelog > ol {
    list-style: none;
    padding: var(--dialog-content-padding);
    overflow: auto;
}

dialog#changelog > ol > li > * {
    padding-left: var(--dialog-content-padding);
}

dialog#changelog > ol > li > ol,
dialog#changelog > ol > li > ul {
    padding-left: calc(var(--standard-font-size) * 1.5);
}

dialog#changelog > ol > li > h2 {
    padding-left: 0px;
    font-size: calc(var(--standard-font-size) * 1.5);
}

dialog#changelog > ol > li > h3 {
    font-size: var(--standard-font-size);
}

dialog#changelog > ol > li > ul{
    list-style-position: outside;
    list-style-type: '- '
}
header > span#project-admin {
    grid-area: logos;
    justify-self: end;
    margin-top: 0.3rem;
    white-space: nowrap;
    display: flex;
    flex-direction: row;
}

img.dfg-logo {
    height: calc(var(--header-height) - 0.7rem);
    width: auto;
}

img.nadw-logo {
    height: calc(var(--header-height) - 0.5rem);
    width: auto;
}

nav.qd-nav {
    grid-area: nav;
    justify-self: center;
    align-self: end;
    margin-bottom: calc(var(--standard-font-size) / 2);
}

@media (max-width: 1000px) {
    header.qd-header {
        grid-template-areas: "hamburger logo badges logos"
                             "extras    extras extras extras"
                             "nav       nav    nav    nav";
        grid-template-columns: auto auto auto 1fr;
    }

    #hamburger-dropdown {
        grid-area: extras;
        justify-self: stretch;
    }

    input#toggle-mobile-nav:checked ~ #hamburger-dropdown {
        position: static;
        background: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        min-width: auto;
    }

    nav.qd-nav {
        display: none;
        justify-self: stretch;
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav {
        display: block;
        border-top: var(--handle-size) solid var(--dividing-line-color);
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu > li {
        width: auto;
        border-bottom: 1px solid var(--dividing-line-color);
        font-family: var(--interface-font);
        font-size: var(--standard-font-size);
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu > li > a {
        display: block;
        padding: 0.5rem 1rem;
    }

    hr#main-menu-underline {
        display: none;
    }
}

nav.qd-nav > menu {
    white-space: nowrap;
}

menu li {
    display: inline-block;
    text-align: center;
    margin: 0;
    text-decoration: none;
    color: #333;
}

menu li a {
    font-family: var(--interface-font);
}
  
li#dictionary-choice {
    width: calc(var(--standard-font-size) * 5);
}
  
li#concordance-choice {
    width: calc(var(--standard-font-size) * 7);
}

li#texts-choice {
    width: calc(var(--standard-font-size) * 4);
}

li#faq-choice {
    width: calc(var(--standard-font-size) * 3);
}

li#dictionary-choice:hover ~ hr#main-menu-underline {
    width: calc(var(--standard-font-size) * 5);
    margin-left: 0px;
}

li#concordance-choice:hover ~ hr#main-menu-underline {
    width: calc(var(--standard-font-size) * 7);
    margin-left: calc(var(--standard-font-size) * 5);
}

li#texts-choice:hover ~ hr#main-menu-underline {
    width: calc(var(--standard-font-size) * 4);
    margin-left: calc(var(--standard-font-size) * 12);
}

li#faq-choice:hover ~ hr#main-menu-underline {
    width: calc(var(--standard-font-size) * 3);
    margin-left: calc(var(--standard-font-size) * 16);
}

hr#main-menu-underline.dictionary-choice {
    width: calc(var(--standard-font-size) * 5);
    margin-left: 0px;
}

hr#main-menu-underline.concordance-choice {
    width: calc(var(--standard-font-size) * 7);
    margin-left: calc(var(--standard-font-size) * 5);
}

hr#main-menu-underline.texts-choice {
    width: calc(var(--standard-font-size) * 4);
    margin-left: calc(var(--standard-font-size) * 12);
}

hr#main-menu-underline.faq-choice {
    width: calc(var(--standard-font-size) * 3);
    margin-left: calc(var(--standard-font-size) * 16);
}

a.qd-nav-choice {
    font-weight: 600;
    color: var(--nav-text-color);
    text-decoration: none;
    cursor: pointer;
}

a.qd-nav-choice:hover {
    color: var(--nav-hover-color);
}

a#dictionary-label.active-menu,
a#concordance-label.active-menu,
a#faq-label.active-menu,
a#texts-label.active-menu,
a#search-label.active-menu {
    color: var(--standard-color);
}

hr#main-menu-underline {
    height: .25rem;
    width: calc(var(--standard-font-size) * 5);
    margin: 0;
    background: var(--nav-hover-color);
    border: none;
    transition: .3s ease-in-out;
}

select.qd-language-selector {
    margin-right: 1rem;
    padding-left: 0.5rem;  
    align-self: center;
}

main.qd-main {
    flex-grow: 4;
    overflow: hidden;
    /* padding-top: calc(var(--body-padding) / 2);
    padding-left: var(--body-padding);
    padding-right: var(--body-padding); */
    border-bottom: var(--handle-size) solid var(--secondary-color);
}
        
iframe {
    display: block;
    border: none;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#dictionary-panel,
#concordance-panel,
#faq-panel,
#texts-panel,
#search-panel {
    display: none !important;
    height: 100%;
}

#dictionary-panel.active-panel,
#concordance-panel.active-panel,
#faq-panel.active-panel,
#texts-panel.active-panel,
#search-panel.active-panel {
    display: flex !important;
}

span.project-support > a + a {
    margin-left: var(--standard-font-size);
}

.visuallyhidden {
    position: absolute;
    overflow: hidden;
    clip: rect(0 0 0 0);
    height: 1px; width: 1px;
    margin: -1px; padding: 0; border: 0;
}

/* Hamburger icon — visible at all sizes */
#toggle-mobile-nav-label {
    display: block;
    grid-area: hamburger;
    justify-self: start;
    align-self: center;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: var(--nav-text-color);
    user-select: none;
}

/* Hamburger dropdown — hidden until toggled */
#hamburger-dropdown {
    display: none;
    font-family: var(--interface-font);
}

#hamburger-dropdown *,
#hamburger-dropdown select,
#hamburger-dropdown button {
    font-family: var(--interface-font);
    font-size: var(--standard-font-size);
    color: var(--nav-text-color);
}

/* Hamburger dropdown item styles */
.menu-extras > .menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--dividing-line-color);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: inherit;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    width: 100%;
    text-align: start;
    box-sizing: border-box;
    text-decoration: none;
}

.menu-extras > .menu-item:last-child,
.menu-extras > .menu-item:last-child:not([hidden]) ~ .menu-item:last-child {
    border-bottom: none;
}

.menu-extras > .menu-item > select {
    font: inherit;
    font-weight: normal;
    margin-inline-start: auto;
    border: 1px solid var(--dividing-line-color);
    border-radius: var(--border-radius-small);
    padding: 0.15rem 0.3rem;
    background: var(--standard-contrast-color);
    cursor: pointer;
}

#user-display-name {
    cursor: default;
    font-weight: 600;
}

#user-actions:not([hidden]) {
    display: flex;
    flex-direction: column;
}

#user-actions > button {
    display: block;
    padding: 0.35rem 1rem 0.35rem 2rem;
    border: none;
    border-bottom: 1px solid var(--dividing-line-color);
    background: none;
    cursor: pointer;
    font: inherit;
    font-weight: normal;
    color: inherit;
    text-align: start;
    width: 100%;
}

#user-actions > button:last-child {
    border-bottom: none;
}

#user-actions > button:hover {
    background-color: var(--primary-color);
}

/* Desktop popover — when hamburger is checked */
input#toggle-mobile-nav:checked ~ #hamburger-dropdown {
    display: block;
    position: absolute;
    top: 100%;
    left: var(--body-padding);
    z-index: 100;
    background-color: var(--standard-contrast-color);
    border: 1px solid var(--dividing-line-color);
    border-radius: var(--border-radius-small);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 12rem;
}

/* ========== Mobile layout (< 1000px) ========== */
@media (max-width: 1000px) {
    :root {
        --body-padding: 0.5rem;
    }

    header.qd-header {
        grid-template-areas: "hamburger logo badges        logos"
                             "extras    extras  extras      extras"
                             "nav       nav     nav         nav";
        grid-template-columns: auto auto auto 1fr;
        justify-items: start;
        padding: 0 var(--body-padding);
    }

    header.qd-header > span#project-admin {
        justify-self: end;
    }

    #hamburger-dropdown {
        grid-area: extras;
        justify-self: stretch;
    }

    .qd-header-badge {
        font-size: calc(var(--standard-font-size) * 0.5);
        padding: 1px calc(var(--standard-font-size) / 4);
    }

    #project-title {
        --title-font-size: calc(var(--standard-font-size) * 1.4);
        font-size: var(--title-font-size);
    }

    #project-subtitle {
        font-size: calc(var(--standard-font-size) * 0.7);
        margin-top: calc(var(--standard-font-size) * -0.45);
        margin-left: calc(var(--standard-font-size) * 1.7);
    }

    /* Institutional logos — small on mobile */
    header > span#project-admin {
        justify-self: end;
        align-self: center;
        margin-top: 0;
    }

    img.dfg-logo {
        height: 1.2rem;
    }

    img.nadw-logo {
        height: 1.2rem;
    }

    span.project-support > a + a {
        margin-left: 0.25rem;
    }

    /* Nav hidden by default on mobile */
    nav.qd-nav {
        display: none;
        justify-self: stretch;
    }

    /* Nav shown when hamburger is checked */
    input#toggle-mobile-nav:checked ~ nav.qd-nav {
        display: block;
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu > li {
        width: auto;
        border-bottom: 1px solid var(--dividing-line-color);
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu > li > a {
        display: block;
        padding: 0.5rem 1rem;
    }

    /* Mobile: hamburger dropdown shown in-flow (override desktop popover) */
    input#toggle-mobile-nav:checked ~ #hamburger-dropdown {
        display: block;
        position: static;
        background: none;
        border: none;
        border-top: var(--handle-size) solid var(--tertiary-color);
        border-radius: 0;
        box-shadow: none;
        min-width: auto;
    }

    input#toggle-mobile-nav:checked ~ nav.qd-nav > menu > li {
        font-family: var(--interface-font);
        font-size: var(--standard-font-size);
    }

    /* Hide the animated underline on mobile */
    hr#main-menu-underline {
        display: none;
    }

    /* Dialogs full-width on mobile */
    section#messaging > dialog,
    section#messaging > dialog#recent-articles-dialog {
        max-width: 90vw;
        max-height: 70dvh;
    }

    section#messaging > dialog#recent-articles-dialog {
        top: 50%;
        height: 70dvh;
    }
}

/* ========== Phone layout (< 430px) ========== */
@media (max-width: 430px) {
    :root {
        --body-padding: 0.25rem;
    }

    header.qd-header > span#project-admin {
        align-self: start;
        margin-top: 0;
        position: relative;
        top: 0.45em;
    }

    span.project-support {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }

    span.project-support > a + a {
        margin-left: 0;
    }

    img.dfg-logo {
        height: 1rem;
    }

    img.nadw-logo {
        height: 1.3rem;
    }
}
