/* Variables */

:root {
    --background: var(--cd-grey-10);
    --text: #fff;
    --text-muted: var(--cd-grey-60);
    --primary: var(--cd-sea-green-60);
    --primary-hover: var(--cd-sea-green-70);
    --surface: var(--cd-grey-20);
    --error-bg: var(--cd-red-40);
    --error-hover: var(--cd-red-50);
    --error-text: var(--cd-red-80);
    --success-bg: var(--cd-sea-green-40);
    --success-text: var(--cd-sea-green-80);
}

/* Reset */

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

/* Layout */

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--background);
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    line-height: 1.5;
}

body {
    display: flex;
    flex-direction: column;
}

.main {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    padding: 2rem;
    min-height: 0;
    overflow: hidden;
}

/* Header */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-left a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
}

.header-logo {
    height: 2rem;
}

.header-brand {
    font-size: 1.1rem;
    font-weight: 600;
}

.header-board {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.6;
    margin-left: 0.5rem;
}

.header-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.header-user {
    font-size: 0.9rem;
    font-weight: 300;
    opacity: 0.6;
}

.header-link {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.header-link:hover {
    opacity: 1;
}

.header-link-danger {
    color: var(--error-text);
}

/* Toast messages */

.toast-container {
    position: fixed;
    top: 5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    animation: toast-in-out 5s ease forwards;
}

.toast.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.toast.success {
    background: var(--success-bg);
    color: var(--success-text);
}

@keyframes toast-in-out {
    0%   { opacity: 0; transform: translateY(-1rem); }
    10%  { opacity: 1; transform: translateY(0); }
    80%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-1rem); }
}

/* Index page */

.page-index {
    background:
        radial-gradient(ellipse at 0% 100%, var(--cd-rose-40) 15%, var(--cd-red-50), transparent 80%),
        radial-gradient(ellipse at top right, var(--cd-yellow-70), var(--cd-orange-60), transparent 90%),
        radial-gradient(ellipse at 50% 50%, transparent, var(--cd-red-60));
}

.welcome-grid {
    display: grid;
    grid-template-columns: 1fr 3fr;
    align-items: center;
    gap: 4rem;
    max-width: 900px;
    width: 100%;
}

.welcome-logo img {
    width: 100%;
    max-height: 200px;
    margin-left: auto;
    display: block;
}

.welcome-text h1 {
    font-size: 3rem;
    font-weight: 300;
}

.welcome-text h1 strong {
    font-weight: 600;
}

.welcome-text .tagline {
    font-size: 1.25rem;
    font-weight: 300;
    color: var(--text);
    text-transform: uppercase;
}

.board-list {
    list-style: none;
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.board-list li a {
    display: inline-block;
    padding: 0.4rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, border-color 0.2s;
}

.board-list li a:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text);
}

/* Forms & buttons */

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.board-form {
    display: flex;
    gap: 1rem;
    flex: 1;
}

.board-form [name="board_name"] {
    flex: 1;
    min-width: 0;
}

.board-form [name="board_areas"] {
    flex: 2;
    min-width: 0;
}

.input {
    padding: 0.75rem 1rem;
    background: transparent;
    border: 3px solid var(--text);
    border-radius: 8px;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    outline: none;
}

.input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.input:focus {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.input-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-width: 2px;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--primary);
    border: none;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 4px solid var(--text);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--error-bg);
}

.btn-danger:hover {
    background: var(--error-hover);
}

/* Board */

.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.board-container {
    display: grid;
    grid-template-columns: 1fr 3fr;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: calc((100vh - 8rem) * 16 / 9);
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    container-type: inline-size;
}

.board-panel {
    position: relative;
    overflow: hidden;
}

.board-panel-title {
    font-size: 1cqw;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1cqw;
    opacity: 0.5;
}

.board-local {
    border-right: 2px solid rgba(255, 255, 255, 0.1);
}

/* Board areas */

.board-areas {
    position: absolute;
    inset: 0;
    display: grid;
    pointer-events: none;
}

.board-area {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.board-area-title {
    font-size: 1.5cqw;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.15;
}

/* Sticky notes */

.sticky-note {
    width: 10cqw;
    cursor: grab;
    user-select: none;
}

.sticky-note-card {
    aspect-ratio: 16 / 9;
    padding: 0.7cqw;
    border-radius: 0.4cqw;
    color: #333;
    font-size: 0.8cqw;
    font-weight: 500;
    box-shadow: 0 0.3cqw 0.6cqw rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sticky-note:hover .sticky-note-card {
    box-shadow: 0 0.5cqw 1cqw rgba(0, 0, 0, 0.3);
}

.sticky-note.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.sticky-note.synced {
    animation: note-pulse 0.6s ease;
}

@keyframes note-pulse {
    0%   { transform: scale(1); filter: brightness(1); }
    30%  { transform: scale(1.06); filter: brightness(1.3); }
    100% { transform: scale(1); filter: brightness(1); }
}

.sticky-note.readonly {
    cursor: default;
}

.sticky-note-author {
    font-size: 0.55cqw;
    font-weight: 600;
    opacity: 0.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sticky-note-content {
    flex: 1;
    overflow-y: auto;
    outline: none;
    word-break: break-word;
    white-space: pre-wrap;
}

.sticky-note-content[contenteditable="true"] {
    cursor: text;
    user-select: text;
}

.sticky-note:has(.sticky-note-content[contenteditable="true"]) {
    cursor: text;
    user-select: text;
}

/* Sticky note toolbar */

.sticky-note-toolbar {
    display: none;
    align-items: center;
    gap: 0.3cqw;
    padding-top: 0.3cqw;
}

.sticky-note:hover .sticky-note-toolbar {
    display: flex;
}

.sticky-note.readonly .sticky-note-toolbar {
    display: none;
}

.sticky-note-palette {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3cqw;
    flex: 1;
}

.palette-dot {
    width: 1cqw;
    height: 1cqw;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

.palette-dot:hover {
    transform: scale(1.3);
}

.sticky-note-delete {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2cqw;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.2cqw;
}

.sticky-note-delete:hover {
    color: #fff;
}

/* Modal */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000000001;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
    line-height: 1;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.invite-result {
    display: flex;
    gap: 0.5rem;
}

.invite-result .input-sm {
    flex: 1;
    min-width: 0;
}
