/*
    main.css is shared by every page of this template.
    It is kept plain on purpose: one column, the system font, thin borders and no colors other than links.
*/

* {
    box-sizing: border-box;
}

html {
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #222;
    background: #fff;
}

body {
    max-width: 42rem;
    margin: 0 auto;
    padding: 1rem;
}

/* Text */

h1 {
    font-size: 1.75rem;
    line-height: 1.25;
    margin: 1rem 0 .5rem;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin: 2rem 0 .5rem;
}

h3 {
    font-size: 1rem;
    margin: 1.5rem 0 .5rem;
}

p,
ul,
ol,
table,
pre,
figure {
    margin: 0 0 1rem;
}

a {
    color: #0645ad;
}

small {
    color: #555;
}

hr {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 2rem 0;
}

pre {
    overflow: auto;
    padding: .5rem;
    border: 1px solid #ddd;
}

img,
video {
    max-width: 100%;
    height: auto;
}

[role="status"]:empty {
    display: none;
}

/* Breadcrumb at the top of every page but the index */

body > header {
    padding-bottom: .5rem;
    border-bottom: 1px solid #ddd;
    font-size: .875rem;
}

body > header ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

body > header li {
    display: inline;
}

body > header li + li::before {
    content: "/";
    margin: 0 .5rem;
    color: #999;
}

/* Menu on the index page: a link and a one line description per feature */

.menu ul {
    list-style: none;
    padding: 0;
}

.menu li {
    padding: .75rem 0;
    border-top: 1px solid #ddd;
}

.menu li:last-child {
    border-bottom: 1px solid #ddd;
}

.menu p {
    margin: 0;
    color: #555;
}

/* Forms */

form {
    margin: 0 0 1.5rem;
}

fieldset {
    border: 1px solid #ddd;
    padding: .5rem 1rem;
    margin: 0 0 1rem;
}

legend {
    padding: 0 .25rem;
}

label {
    display: block;
    margin: 0 0 .75rem;
}

input,
textarea,
select,
button {
    font: inherit;
    color: inherit;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
textarea,
select {
    display: block;
    width: 100%;
    padding: .4rem .5rem;
    margin: .25rem 0 0;
    border: 1px solid #999;
    border-radius: 0;
    background: #fff;
}

input[type="file"] {
    display: block;
    margin: .25rem 0 0;
}

textarea {
    min-height: 6rem;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    margin: 0 .35rem 0 0;
    vertical-align: middle;
}

button {
    padding: .4rem 1rem;
    border: 1px solid #333;
    border-radius: 0;
    background: #f3f3f3;
    cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
    opacity: .5;
    cursor: default;
}

/* A text field with its button on the same line (chat, comments, verification code) */

.inline-form {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
}

.inline-form label {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.inline-form button {
    flex: none;
}

/* Tables */

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

th,
td {
    padding: .4rem .5rem;
    border: 1px solid #ddd;
    text-align: left;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

th {
    background: #f3f3f3;
    font-weight: 600;
}

td button {
    padding: .2rem .6rem;
}

/* Dialogs */

dialog {
    width: calc(100% - 2rem);
    max-width: 24rem;
    padding: 1rem;
    border: 1px solid #333;
}

dialog::backdrop {
    background: rgba(0, 0, 0, .4);
}

dialog h2 {
    font-size: 1.1rem;
    margin: 0 0 .5rem;
}

dialog form {
    margin: 0;
}

/* Database page: photo posts */

article {
    border: 1px solid #ddd;
    padding: 1rem;
    margin: 0 0 1rem;
    overflow-wrap: anywhere;
}

article header p {
    margin: 0;
}

article header button {
    padding: .2rem .6rem;
    margin-left: .5rem;
}

article img {
    display: block;
    width: 100%;
    margin: .75rem 0;
}

article h3 {
    margin-top: 1rem;
}

.comments {
    list-style: none;
    padding: 0;
    margin: 0 0 .5rem;
    border-top: 1px solid #ddd;
}

.comments li {
    padding: .5rem 0;
    border-bottom: 1px solid #ddd;
}

.comments p {
    margin: 0;
}

#img_preview {
    max-height: 20rem;
    width: auto;
    margin: 0 0 1rem;
    border: 1px solid #ddd;
}

/* Realtime page: chat */

.chat {
    display: flex;
    gap: 1rem;
    margin: 0 0 1rem;
}

#chatMessages,
#participants {
    height: 20rem;
    overflow: auto;
    padding: .5rem;
    border: 1px solid #ddd;
    margin: 0;
}

#chatMessages {
    flex: 1;
    min-width: 0;
}

#chatMessages p {
    margin: 0 0 .25rem;
    overflow-wrap: anywhere;
}

#chatMessages .notice {
    color: #555;
    font-style: italic;
}

#participants {
    flex: 0 0 10rem;
    list-style: none;
}

#participants button {
    padding: 0;
    border: 0;
    background: none;
    color: #0645ad;
    text-decoration: underline;
}

/* WebRTC page: video call */

.videos {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 1rem;
}

.videos video {
    flex: 1 1 14rem;
    aspect-ratio: 4 / 3;
    background: #000;
    border: 1px solid #ddd;
}

#rtcMessages {
    max-height: 10rem;
    overflow: auto;
    padding: .5rem;
    border: 1px solid #ddd;
    list-style: none;
}

#rtcMessages li {
    overflow-wrap: anywhere;
}

/* Small screens */

@media (max-width: 36rem) {
    h1 {
        font-size: 1.5rem;
    }

    .chat {
        flex-direction: column;
    }

    #participants {
        flex-basis: auto;
        height: auto;
        max-height: 8rem;
    }
}
