/* Font Face Definitions */
@font-face {
    font-family: "Ubuntu local";
    src: url("../fonts/Ubuntu-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Ubuntu local";
    src: url("../fonts/Ubuntu-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Ubuntu Mono local";
    src: url("../fonts/UbuntuMono-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-size-small: clamp(0.8rem, 1.8vmin, 1rem);
    --font-size-medium: clamp(0.9rem, 2.2vmin, 1.1rem);
    --font-size-large: clamp(1.2rem, 2.5vmin, 1.8rem);
    --spacing: clamp(0.5rem, 4vmin, 2rem);
    --border-radius: clamp(0.75rem, 2vmin, 1.25rem);

    /* Color Scale */
    --color-background: #313039;
    --color-tile: #00000070;
    --color-tile-hover: #00000075;
    --color-100: #ffffffd0;
    --color-300: #ffffffa0;
    --color-500: #ffffff70;
    --color-700: #00000050;
    --color-800: #00000010;
    --color-900: #00000020;

    --box-shadow: 0 0 16px rgba(0, 0, 0, 0.15);
    --box-shadow-hover: 0 0 32px rgba(0, 0, 0, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    height: 100dvh;
    font-family:
        "Ubuntu local",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    overflow: hidden;
}

* {
    scrollbar-width: none;
}

*::-webkit-scrollbar {
    display: none;
}

main {
    height: 100dvh;
    padding: var(--spacing);
    display: grid;
    grid-template-rows: 2fr 3fr;
    grid-template-columns: repeat(20, 1fr);
    gap: var(--spacing);
}

section {
    background-color: var(--color-tile);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing) * 0.75);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

section:hover {
    background-color: var(--color-tile-hover);
    box-shadow: var(--box-shadow-hover);
}

section:nth-child(1) {
    grid-row: 1;
    grid-column: 1 / 13;
}

section:nth-child(2) {
    grid-row: 1;
    grid-column: 13 / 21;
}

section:nth-child(3) {
    grid-row: 2;
    grid-column: 1 / 8;
}

section:nth-child(4) {
    grid-row: 2;
    grid-column: 8 / 13;
}

section:nth-child(5) {
    grid-row: 2;
    grid-column: 13 / 21;
}

section:nth-child(1) {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    color: var(--color-100);
    position: relative;
}

section:nth-child(1):hover::after {
    content: "Ctrl+Click: Export • Alt+Click: Import";
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-tile);
    color: var(--color-300);
    padding: calc(var(--spacing) * 0.25) calc(var(--spacing) * 0.5);
    border-radius: calc(var(--border-radius) * 0.5);
    font-size: calc(var(--font-size-small) * 0.8);
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
}

section:nth-child(1) > div {
    height: 100%;
    width: 50%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 2;
}

section:nth-child(1) > div > div:first-child {
    align-self: flex-start;
}

section:nth-child(1) > div > div:last-child {
    align-self: flex-start;
}

section:nth-child(1) div[id="date-display"],
section:nth-child(1) div[id="day-display"],
section:nth-child(1) div[id="time-display"] {
    font-size: var(--font-size-large);
    font-family: "Ubuntu local", sans-serif;
    font-weight: 700;
    line-height: 1.5;
}

section:nth-child(1) div[id="day-display"] {
    font-weight: 400;
}

/* Global monospace for all section content */
section * {
    font-family: "Ubuntu Mono local", monospace;
}

/* Override for h2 headers */
section h2 {
    font-family: "Ubuntu local", sans-serif;
}

/* Override for first tile */
section:nth-child(1) * {
    font-family: "Ubuntu local", sans-serif;
}

section:nth-child(n + 3) h2 {
    font-size: var(--font-size-medium);
    font-weight: 700;
    color: var(--color-100);
    text-align: center;
    margin: 0;
}

section:nth-child(2) {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

section:nth-child(2) img {
    position: absolute;
    top: calc(var(--spacing) * 0.75);
    right: calc(var(--spacing) * 0.75);
    width: calc(var(--font-size-medium) * 1);
    height: calc(var(--font-size-medium) * 1);
    cursor: pointer;
    opacity: 0.4;
    z-index: 10;
}

section:nth-child(2) img:hover {
    opacity: 0.8;
}

section:nth-child(2) h2 {
    text-align: center;
    margin-bottom: calc(var(--spacing) * 0.5);
    font-size: var(--font-size-medium);
    font-weight: 700;
    color: var(--color-100);
    margin: 0 0 calc(var(--spacing) * 0.5) 0;
}

section:nth-child(2) ul {
    flex: 1;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    margin-bottom: calc(var(--spacing) * 0.5);
    min-height: 0;
}

section:nth-child(2) li {
    display: flex;
    align-items: flex-start;
    margin-bottom: calc(var(--spacing) * 0.2);
    cursor: pointer;
    position: relative;
    margin-right: 10px;
}

section:nth-child(2) li::before {
    content: "";
    width: calc(var(--font-size-small) * 1);
    height: calc(var(--font-size-small) * 1);
    border-radius: 50%;
    background-color: var(--color-700);
    margin-right: calc(var(--spacing) * 0.5);
    margin-top: calc(var(--font-size-small) * 0.25);
    flex-shrink: 0;
}

section:nth-child(2) li.completed::before {
    background-color: var(--color-500);
}

section:nth-child(2) li span {
    color: var(--color-300);
    font-size: var(--font-size-small);
    line-height: 1.4;
}

section:nth-child(2) li.completed span {
    text-decoration: line-through;
    opacity: 0.6;
}

section:nth-child(2) input[type="text"]#todo-input {
    background-color: var(--color-900);
    border: none;
    border-radius: calc(var(--border-radius) * 0.5);
    padding: calc(var(--spacing) * 0.2);
    color: var(--color-300);
    font-size: var(--font-size-small);
    outline: none;
    width: 100%;
    text-align: center;
    margin-top: auto;
}

section:nth-child(2) li input {
    background: transparent;
    border: none;
    color: var(--color-100);
    font-size: var(--font-size-small);
    outline: none;
    width: 100%;
    line-height: 1.4;
}

section:nth-child(2) input[type="text"]#todo-input:focus {
    background-color: var(--color-900);
}

section:nth-child(2) input[type="text"]#todo-input::placeholder {
    color: var(--color-300);
    opacity: 0.6;
    font-size: calc(var(--font-size-small) * 0.9);
}

section:nth-child(3) {
    display: flex;
    flex-direction: column;
}

section:nth-child(3) h2 {
    margin-bottom: calc(var(--spacing) * 0.5);
}

section:nth-child(3) > div {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: calc(var(--spacing) * 2.5);
    gap: calc(var(--spacing) * 0.12);
    flex: 1;
    overflow-y: auto;
    align-content: start;
    padding: calc(var(--spacing) * 0.08);
}

section:nth-child(3) > div > div,
section:nth-child(3) > div > a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: none;
    border-radius: calc(var(--border-radius) * 0.5);
    cursor: pointer;
    height: calc(var(--spacing) * 2.5);
    text-decoration: none;
    color: var(--color-300);
    overflow: hidden;
}

section:nth-child(3) > div > a {
    display: block; /* necessario per far funzionare l'ellipsis */
    width: 100%; /* il testo prenderà tutta la larghezza disponibile */
    overflow: hidden; /* nasconde il contenuto eccedente */
    text-align: center; /* centra il testo */
    text-decoration: none;
}

section:nth-child(3) > div > div:hover,
section:nth-child(3) > div > a:hover {
    background-color: var(--color-800);
}

section:nth-child(3) > div > a div {
    height: 100%;
}

section:nth-child(3) > div > a div svg {
    width: calc(var(--font-size-small) * 1.7);
    height: calc(var(--font-size-small) * 1.7);
    margin-bottom: calc(var(--spacing) * 0.25);
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.1));
}

section:nth-child(3) > div > a div img {
    width: calc(var(--font-size-small) * 2);
    height: calc(var(--font-size-small) * 2);
    margin-bottom: calc(var(--spacing) * 0.25);
    flex-shrink: 0;
}

section:nth-child(3) > div > a span {
    font-size: calc(var(--font-size-small) * 0.9);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%;
    overflow-wrap: normal;
}

section:nth-child(3) div > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: calc(var(--spacing) * 0.15);
    height: 100%;
    padding: calc(var(--spacing) * 0.2);
}

section:nth-child(3) input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    background-color: var(--color-900);
    border: none;
    border-radius: calc(var(--border-radius) * 0.25);
    padding: calc(var(--spacing) * 0.1);
    color: var(--color-300);
    font-size: calc(var(--font-size-small) * 0.9);
    outline: none;
    text-align: center;
}

section:nth-child(3) input::placeholder {
    color: var(--color-500);
    opacity: 0.8;
}

section:nth-child(3) input:focus {
    background-color: var(--color-700);
}

section:nth-child(4) {
    display: flex;
    flex-direction: column;
}

section:nth-child(4) h2 {
    margin-bottom: calc(var(--spacing) * 0.5);
}

section:nth-child(4) > div {
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing) * 0.25);
    flex: 1;
    max-height: 100%;
    overflow-y: auto;
}

section:nth-child(4) textarea {
    flex: 1;
    background-color: transparent;
    border: none;
    border-bottom: 4px solid transparent;
    border-radius: calc(var(--border-radius) * 0.5);
    padding: calc(var(--spacing) * 0.3);
    color: var(--color-300);
    font-size: var(--font-size-small);
    outline: none;
    resize: none;
}

section:nth-child(4) textarea.has-content {
    background-color: var(--color-900);
    border-bottom-color: var(--color-700);
}

section:nth-child(4) textarea:hover {
    background-color: var(--color-800);
}

section:nth-child(5) {
    display: flex;
    flex-direction: column;
}

section:nth-child(5) h2 {
    margin-bottom: calc(var(--spacing) * 0.5);
}

section:nth-child(5) textarea {
    flex: 1;
    background-color: transparent;
    border: none;
    border-radius: calc(var(--border-radius) * 0.5);
    padding: calc(var(--spacing) * 0.5);
    color: var(--color-300);
    font-size: var(--font-size-small);
    outline: none;
    resize: none;
    line-height: 1.5;
}
