@font-face {
    font-family: "Inter";
    src: url(fonts/inter.ttf) format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Noto Serif";
    src: url(fonts/noto-serif.ttf) format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root{
    --colour-primary:#232322;
    --colour-secondary:#F7F4ED;
    --colour-weak:#A2A09C;
    --colour-accent:#e4382f;
    --danger:#c62828;
    --border-radius: 0.3rem;
    color: var(--colour-primary);
}

::selection {
  background: #e4382f;
  color: #F7F4ED;
}

::-moz-selection {
  background: #e4382f;
  color: #F7F4ED;
}

details{
    --colour-primary:#F7F4ED;
    --colour-secondary:#232322;
    color: var(--colour-primary);
}

*{
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-weight: 500;
    font-style: normal;
    box-sizing: border-box;
    scrollbar-color: var(--colour-secondary) var(--colour-primary);
    scroll-behavior: smooth;
}

*:focus-visible{
   outline: var(--colour-accent) solid 0.2rem;
}

#dialog-welcome > button:first-of-type:focus-visible{
    outline: none; /* Not a perfect solution, but prevents distracting highlight on load */
}

h1, h2, h3, h4, h5, h6, summary{
    font-family: "Noto Serif", serif;
    font-weight: 500;
    font-style: normal;
    font-variation-settings: "wdth" 100;
    margin:0;
}

html{
    overflow: hidden;
    height: 100vh;
}

body{
    margin: 0;
    background: var(--colour-primary);
    height: 100vh;
}

header{
    display: flex; 
    width: 100vw;
    align-items: center; 
    justify-content: space-between;
    padding: 1rem;
    color: var(--colour-secondary);
    background-color: var(--colour-primary);
    z-index:100;
    height: 4rem;
}

header .brand{
    display: flex; 
    align-items: center;
    gap: 1rem;
}

#version-text{
    color: var(--colour-weak);
    font-size: .8rem;
}

header .controls{
    display: flex; 
    flex-wrap: wrap; 
    gap: .5rem 1rem; 
    align-items: center;
}

button, .import-label{
    cursor: pointer;
    background-color: var(--colour-primary);
    border: 0.1rem solid var(--colour-secondary);
    color: var(--colour-secondary);
    padding: 0.3rem 0.6rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
    text-align: left;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: fit-content;

    transition: all 150ms ease;
}

button:hover, .import-label:hover{
    background-color: var(--colour-secondary);
    color: var(--colour-primary);
}

a{
    color: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.round-button{
    border-radius: 10rem;
    height: 2rem;
    width: 2rem;
    text-align: center;
    padding: 0;
}

label{
    cursor: pointer;
}

input, select, textarea{
    border-radius: var(--border-radius);
    border: solid 0.1rem var(--colour-secondary);
    background-color: white;
    padding: 0.1rem 0.2rem;
}

fieldset{
    border-radius: var(--border-radius);
}

ul{
    list-style: none; 
    padding: 0; 
    margin: 0;
}

main{
    display:flex;
    height: calc(100vh - 4rem);
}

aside{
    color: var(--colour-secondary);
    background-color: var(--colour-primary);
    padding: 1rem; 
    overflow-y: auto;
    width: 22rem !important;
}

aside h3{
    margin: .5rem 0;
}

aside ul{
    padding: 0.5rem;
}

aside ul li{
    padding: .1rem 0;
}

aside details{
    color: var(--colour-secondary);
    background-color: var(--colour-primary);
    margin-bottom: 0.5rem;
}

summary{
    font-size: 1.2rem;
    background-color: var(--colour-secondary);
    color: var(--colour-primary);
    border-bottom: 0.1rem solid var(--colour-primary);
    padding: .5rem 0;
    cursor: pointer;
}

aside section:first-child{
    margin-bottom: 3rem;
}

.stage-wrap{
    border-top-left-radius: 1rem;
    background-color: var(--colour-secondary);
    width: 100%;
    height: 100%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    overflow: auto;
}

.svg-wrap{
    width: 100%; 
    height: 100%;
    overflow: auto; 
    scrollbar-color: var(--colour-primary) var(--colour-secondary);
    background: var(--colour-secondary);
}

#map{
    display:block;
}

.legend-hidden #legend-list,
.legend-hidden #legend-station-list,
.legend-hidden #controls-legend-list{
    display:none
}

.hidden{
    display: none !important;
}

.visually-hidden{
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

dialog{
    background-color: var(--colour-primary);
    color: var(--colour-secondary);
    padding: 1rem; 
    min-width: 30rem;
    max-height: 80vh;
    max-width: min(60vw, 50rem);
    overflow-y: auto;
    border-radius: var(--border-radius);
    border: none;
}

dialog::backdrop{
    background-color: rgba(247, 244, 237, 0.2);
    backdrop-filter: blur(0.1rem);
    animation: backdropIn 0.2s ease;
}

dialog[open] {
    animation: fadeIn 100ms ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes backdropIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.closepopup, dialog > button:first-of-type{
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    height: 2.5rem;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 2rem;
    background: none;
    border-radius: 50rem;
}

dialog button:first-of-type:hover{
    background-color: var(--colour-secondary);
    color: var(--colour-primary);
}

.toggle-label input{
    width: 2rem;
}

.toggle-label input::before{
    content: "";
    height: 1rem;
    width: 2rem;
    display: inline-block;
    border-radius: 50rem;
    background-color: var(--colour-weak);
    cursor: pointer;
}

.toggle-label input:checked::before{
    background-color: var(--colour-secondary);
}

.toggle-label input::after{
    content: "";
    height: 0.75rem;
    width: 0.75rem;
    display: inline-block;
    margin-left: -1.85rem;
    margin-bottom: 0.125rem;
    border-radius: 50rem;
    transition: all 0.1s ease;
    background-color: var(--colour-primary);
    cursor: pointer;
}

.toggle-label input:checked:after{
    margin-left: -0.9rem;
}

#details-map li{
    width: 100%;
    display: flex;
    justify-content: space-between;
}

#details-map li div{
    display: inline-block;
}

dialog label{
    display:flex; 
    gap:.5rem; 
    margin:.5rem 0; 
    align-items:center
}

.popup-actions{
    display:flex; gap:.5rem; 
    justify-content:flex-end; 
    margin-top:1rem
}

.danger{
    border-color:var(--danger);
}

.danger:hover{
    background-color: var(--danger);
    color: var(--colour-secondary);
}

.table-list{
    width:100%; 
    border-collapse:collapse;
}

.table-list th, .table-list td{
    padding:.25rem .35rem; 
    border-bottom: 0.1rem solid var(--colour-secondary);
}

.table-list button{
    margin-right:.35rem;
    border: none;
}

/* station labels (SVG text) */
.station-label{
    font-size: 14px;
    paint-order: stroke;
    stroke: var(--colour-secondary);
    stroke-width: 0.3rem;
    fill: var(--colour-primary);
}

/* grid coord text */
.coord-label{
    font-size:12px; 
    fill: rgba(0,0,0,.5);
}

/* clickable */
svg [data-role="station"]{
    cursor:pointer;
}

svg [data-role="station"]::before{
    content: "henk";
}

svg [data-role="line"]{
    pointer-events: stroke;
}

#legend{
    position: absolute;
    max-width: 30rem;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem;
    background-color: var(--colour-secondary);
    border: solid 0.1rem var(--colour-primary);
    border-radius: var(--border-radius);
}

#toggleAddStationLabel{
    background-color: var(--colour-primary);
    border: 0.1rem solid var(--colour-secondary);
    color: var(--colour-secondary);
    border-radius: var(--border-radius);
    padding: 0.3rem 0.6rem;
    font-size: 1rem;

    transition: all 150ms ease;
}

#toggleAddStationLabel:hover,
#toggleAddStationLabel:has(input:checked){
    background-color: var(--colour-secondary);
    color: var(--colour-primary);
}

#toggleAddStationLabel span{
    display: none;
}

#toggleAddStationLabel input:checked + span{
    display: block;
    position: absolute;
    top: 5rem;
    left: calc((100% + 22rem)/2);
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    border-radius: 50rem;
    font-size: 0.8rem;
    background-color: var(--colour-accent);
    color: var(--colour-secondary)
}

#toggleAddStation{
    display: none;
}

#dialog-changelog{
    ul{
        list-style: square; 
        padding-left: 1.5rem;
        margin-top: 1rem;
    }
    ul li{
        margin-bottom: 1rem;
    }
}

#dialog-export{
    width: auto;
}

#dialog-export > div{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    column-gap: 2rem;
}

#dialog-export *{
    grid-column: 2/3;
}

#export-preview-img{
    width: 100%;
    height: auto;
    border-radius: 0.5rem;
    grid-row: span 6;
}

#dialog-export h3,
#export-preview-img{
    grid-column: 1/2;
}

#dialog-welcome > div{
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

#dialog-welcome div div{
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#dialog-welcome div img{
    width: 100%;
    border-radius: var(--border-radius);
}

#dialog-welcome div button, #dialog-welcome div label{
    display: flex;
    height: auto;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 0.8rem;
    width: 100%;
    height: 100%;
    padding: 0.8rem;
    margin: 0;
}

#dialog-welcome > label{
    display: inline-block;
    width: 49%;
}

#dialog-welcome span{
    margin: auto;
    display: inline-block;
    text-align: right;
    width: 49%;
}

@media print {
  html, body {
    background: var(--colour-secondary) !important;
    height: auto !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  header, aside, dialog{
    display: none !important;
  }

  .stage-wrap {
    border-radius: 0 !important;
    background: var(--colour-secondary) !important;
    width: auto !important;
    height: auto !important;
  }

  .svg-wrap {
    overflow: visible !important;
    background: var(--colour-secondary) !important;
  }

  #map {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }

  #legend {
    position: fixed !important;
    transform: scale(0.8) !important;
    bottom: 0 !important;
    right: 0 !important;
  }

  @page {
    size: auto;
    margin: 0;
  }
}

#mobile-message{
    display: none;
}
 
@media only screen and (max-width: 800px) {
    header, main, dialog{
        display: none !important;
    }

    #mobile-message{
        display: flex !important;
        flex-direction: column;
        color: var(--colour-secondary);
        height: 100vh;
        width: 100vw;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 2rem;
    }
}